Skip to content

Instantly share code, notes, and snippets.

@sirex
Last active November 10, 2017 08:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirex/ddf64bb5697271f8da02 to your computer and use it in GitHub Desktop.
Save sirex/ddf64bb5697271f8da02 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import ast
import configparser
import os.path
import subprocess
restore_filename = '~/.config/autostart/restore-extensions.desktop'
active_extensions = subprocess.check_output(['gsettings', 'get', 'org.gnome.shell', 'enabled-extensions'])
print('Currently active extensions:')
for ext in ast.literal_eval(active_extensions.decode()):
print('-', ext)
config = configparser.ConfigParser()
config.optionxform = str
config['Desktop Entry'] = {
'Type': 'Application',
'Exec': 'gsettings set org.gnome.shell enabled-extensions "%s"' % active_extensions.decode().strip(),
'Hidden': 'false',
'NoDisplay': 'false',
'X-GNOME-Autostart-enabled': 'true',
'Name': 'Restore Extensions',
'Comment': 'Restore enabled extensions on login',
}
with open(os.path.expanduser(restore_filename), 'w') as f:
config.write(f)
print("Command to restore currently active extensions added to", restore_filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment