Copy the Unity launcher from one user to all users - Ask Ubuntu


i add state of art of unity launcher template creating minimal state of art of other users. found method how add apps template, not method, how extract settings of current user.

i trying ensure if editing schema enough set display of logged user real name in panel indicator, well.

you can divide unity launcher's items in application launchers , other items; network related, mounted volumes , such. best copy application launchers other users, since other ones can user specific , / or vary during process.

also note if copy launcher's content user, possible local .desktop files (in ~/.local/share/applications) of locally installed applications example, not appear in other user's unity launcher.

reading current launcher's content

having said that, can read current launcher's content command:

gsettings com.canonical.unity.launcher favorites 

the output list of items current unity launcher.

setting new launcher's content

to set new content launcher, following command used:

gsettings set com.canonical.unity.launcher favorites <list_of_items> 

using script copy launcher user's account

if use script fetch launcher items of first user, write result file, log user's account run script again (together file) set content other user's account, can done in no time. script below made both, depending on argument give (see further below).

how use

  • copy script below empty file, save copy_launcher.py
  • open terminal window in "model user's" account, , run script command:

    python3 /path/to/copy_launcher.py 

    the get -argument of command makes script create text file: saved_launcher.txt, content of current unity launcher. file created in same directory script located.

  • copy both script , saved_launcher.txt file on (for example) usb stick, keep both files in 1 , same directory.
  • log other user's account, open terminal , run script command:

    python3 /path/to/copy_launcher.py set 

    (mind set argument)

the script

#!/usr/bin/env python  import subprocess import os import sys  command = sys.argv[1]  curr_dir = os.path.dirname(os.path.abspath(__file__)) datafile = curr_dir+"/saved_launcher.txt"  def get_current():     get_current = subprocess.check_output(["gsettings", "get", "com.canonical.unity.launcher", "favorites"]).decode("utf-8")     return (str([item item in eval(get_current) if item.startswith("application://")]),             [item item in eval(get_current) if not item.startswith("application://")])  def write_saved():     current_launcher = get_current()[0]     open(datafile, "w") saved:         saved.write(current_launcher)  def read_saved():     open(datafile, "r") saved:         return eval(saved.read())  def set_launcher():     app_section = read_saved(); fixed_section = get_current()[1]     new_launcher = str(app_section+fixed_section)     subprocess.popen(["gsettings", "set", "com.canonical.unity.launcher", "favorites", new_launcher ])   if command == "set":     set_launcher() elif command == "get":     write_saved() 

if you're done, copied unity launcher 1 user another.


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User