Thank you that solved half my problem and was a great help.
I managed to get it to work perfectly for all users. I simplified the script to work while logged in as a member of a group name nginxadmins with sudo privileges.
I run the script to configure user larryâs sublime text. The account for larry was just created and he has never logged into his account which also means he has never launched sublime text. Sublime text is installed on the machine already.
The script does basically two things:
- Creates a mousemap in larryâs account.
- Creates a spoofed sublime text session file which contains barebone settings
I had mentioned previously that if you manually create the mousemap file and run sublime text that it corrupts sublime text and you asked about it. Here is what I discovered, when you launch sublime text it looks for a session file located at /home/larry/.config/sublime-text/Local/Session.sublime_session, if it canât find the file it will allow you to edit or create any file, but when you try to save it an error dialog box says it is unable to find the session file. If try to exit sublime text the error keeps displaying and it wonât let you exit âcorruptedâ.
Normally the file /home/larry/.config/sublime-text/Local/Session.sublime_session would exist but in this case larry has never logged into his ubuntu account after it was created therefore it doesnât exist. In fact the /home/larry/.config/sublime-text is created the first time you run sublime text.
Here is the script that creates the basic directories, creates the mousemap and creates a minimal session file to kick start sublime text when he finally logs in and runs sublime text.
#!/bin/bash
# Note: I am running this script from another user who is a member of nginxadmins group to gain permission to larry's home
# Create mousemap for each user
sudo mkdir -p "/home/larry/.config/sublime-text"
sudo chown larry:nginxadmins "/home/larry/.config/sublime-text"
sudo mkdir -p "/home/larry/.config/sublime-text/Packages/User/"
sudo chown larry:nginxadmins "/home/larry/.config/sublime-text/Packages"
sudo mkdir -p "/home/larry/.config/sublime-text/Packages/User/"
sudo chown larry:nginxadmins "/home/larry/.config/sublime-text/Packages/User/"
echo '[
{
"button": "button3",
"command": "noop"
}
]' | sudo tee /home/larry/.config/sublime-text/Packages/User/'Default (Linux).sublime-mousemap' > /dev/null
sudo chown larry:nginxadmins /home/larry/.config/sublime-text/Packages/User/'Default (Linux).sublime-mousemap'
echo "Sublime Text mouse wheel click has been configured successfully!"
# Create Session.sublime_session file to spoof sublime text session
sudo mkdir -p "/home/larry/.config/sublime-text/Local"
sudo chown larry:nginxadmins "/home/larry/.config/sublime-text/Local"
echo '{
"file_history":
[
],
"folder_history":
[
],
"last_version": 4192,
"last_window_id": 6,
"log_indexing": false,
"next_update_check": 1741894148,
"settings":
{
"new_window_full_screen": false,
"new_window_height": 600.0,
"new_window_maximized": false,
"new_window_position":
[
26.0,
96.0
],
"new_window_settings":
{
"auto_complete":
{
"selected_items":
[
]
},
"build_system_choices":
[
],
"build_varint": "",
"command_palette":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"console":
{
"height": 0.0,
"history":
[
]
},
"distraction_free":
{
"menu_visible": true,
"show_minimap": false,
"show_open_files": false,
"show_tabs": false,
"side_bar_visible": false,
"status_bar_visible": false
},
"file_history":
[
],
"find":
{
"height": 26.0
},
"find_in_files":
{
"height": 0.0,
"where_history":
[
]
},
"find_state":
{
"case_sensitive": false,
"find_history":
[
"$user",
"udp_url"
],
"highlight": true,
"in_selection": false,
"preserve_case": false,
"regex": false,
"replace_history":
[
"larry"
],
"reverse": false,
"scrollbar_highlights": true,
"show_context": true,
"use_buffer2": true,
"use_gitignore": true,
"whole_word": false,
"wrap": true
},
"incremental_find":
{
"height": 26.0
},
"input":
{
"height": 0.0
},
"menu_visible": true,
"output.find_results":
{
"height": 0.0
},
"pinned_build_system": "",
"replace":
{
"height": 48.0
},
"save_all_on_build": true,
"select_file":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"select_project":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"select_symbol":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"show_minimap": true,
"show_open_files": false,
"show_tabs": true,
"side_bar_visible": true,
"side_bar_width": 150.0,
"status_bar_visible": true,
"template_settings":
{
}
},
"new_window_width": 1803.0
},
"windows":
[
{
"auto_complete":
{
"selected_items":
[
]
},
"buffers":
[
],
"build_system": "",
"build_system_choices":
[
],
"build_varint": "",
"command_palette":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"console":
{
"height": 0.0,
"history":
[
]
},
"distraction_free":
{
"menu_visible": true,
"show_minimap": false,
"show_open_files": false,
"show_tabs": false,
"side_bar_visible": false,
"status_bar_visible": false
},
"file_history":
[
],
"find":
{
"height": 26.0
},
"find_in_files":
{
"height": 0.0,
"where_history":
[
]
},
"find_state":
{
"case_sensitive": false,
"find_history":
[
"$user",
"udp_url"
],
"highlight": true,
"in_selection": false,
"preserve_case": false,
"regex": false,
"replace_history":
[
"larry"
],
"reverse": false,
"scrollbar_highlights": true,
"show_context": true,
"use_buffer2": true,
"use_gitignore": true,
"whole_word": false,
"wrap": true
},
"groups":
[
{
"sheets":
[
]
}
],
"incremental_find":
{
"height": 26.0
},
"input":
{
"height": 0.0
},
"layout":
{
"cells":
[
[
0,
0,
1,
1
]
],
"cols":
[
0.0,
1.0
],
"rows":
[
0.0,
1.0
]
},
"menu_visible": true,
"output.find_results":
{
"height": 0.0
},
"pinned_build_system": "",
"position": "0,0,0,0,0,26,23,1829,623,1920,1080,0",
"project": "",
"replace":
{
"height": 48.0
},
"save_all_on_build": true,
"select_file":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"select_project":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"select_symbol":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"selected_group": 0,
"settings":
{
},
"show_minimap": true,
"show_open_files": false,
"show_tabs": true,
"side_bar_visible": true,
"side_bar_width": 150.0,
"status_bar_visible": true,
"template_settings":
{
},
"window_id": 1,
"workspace_name": ""
}
],
"workspaces":
{
"recent_workspaces":
[
]
}
}
' | sudo tee /home/larry/.config/sublime-text/Local/Session.sublime_session > /dev/null
sudo chown larry:nginxadmins /home/larry/.config/sublime-text/Local/Session.sublime_session
echo "Sublime Text Session Spoof has been configured successfully!"