Last active
November 10, 2017 08:20
-
-
Save sirex/ddf64bb5697271f8da02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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