1#!/usr/local/bin/python3.8 2 3""" Launch the cinnamon-settings utility, or a specific settings module 4 5Usage: 6 To open System Settings: 7$ cinnamon-settings 8 9 To open the settings of a particular module: 10$ cinnamon-settings module_name 11 12 To open the settings of an applet, a desklet or an extension downloaded by the user: 13$ cinnamon-settings applets|desklets|extensions UUID 14Example: 15$ cinnamon-settings applets SpicesUpdate@claudiux 16 17 To add a xlet on a specific panel: 18$ cinnamon-settings applets|desklets|extensions panel1|panel2|panel3|panel4 19 20 To open a particular tab of the settings of a module, use the '--tab=' or '-t' argument: 21$ cinnamon-settings module_name --tab=x 22or 23$ cinnamon-settings module_name -t x 24(where x is the tab name (e.g. download) or the tab number (e.g. 1)) 25Example: 26$ cinnamon-settings applets --tab=download 27 28 To open the 'download' tab of a type of Spices (applets, desklets, extensions, themes), sorting 29 them by 'name', 'score', 'date' or 'installed', use the '--sort=' or '-s' argument: 30$ cinnamon-settings applets|desklets|extensions|themes --tab=1 --sort=name|score|date|installed 31or 32$ cinnamon-settings applets|desklets|extensions|themes -t 1 -s name|score|date|installed 33Example: 34$ cinnamon-settings applets -t 1 -s date 35 36Available modules, their tab names and corresponding numbers: 37 "MODULE_NAME": {"TAB_NAME": TAB_NUMBER, ... } 38 "accessibility":{"visual": 0, "keyboard": 1, "typing": 2, "mouse": 3}, 39 "applets": {"installed": 0, "more": 1, "download": 1}, 40 "backgrounds": {"images": 0, "settings": 1}, 41 "default": {"preferred": 0, "removable": 1}, 42 "desklets": {"installed": 0, "more": 1, "download": 1, "general": 2}, 43 "effects": {"effects": 0, "customize": 1}, 44 "extensions": {"installed": 0, "more": 1, "download": 1}, 45 "keyboard": {"typing": 0, "shortcuts": 1, "layouts": 2}, 46 "mouse": {"mouse": 0, "touchpad": 1}, 47 "power": {"power": 0, "batteries": 1, "brightness": 2}, 48 "screensaver": {"settings": 0, "customize": 1}, 49 "sound": {"output": 0, "input": 1, "sounds": 2, "applications": 3, "settings": 4}, 50 "themes": {"themes": 0, "download": 1, "options": 2}, 51 "windows": {"titlebar": 0, "behavior": 1, "alttab": 2}, 52 "workspaces": {"osd": 0, "settings": 1} 53 54Available types of sort, and corresponding numbers: 55 "name":0, "score":1, "date":2, "installed":3 56""" 57 58import getopt 59import os 60import sys 61 62def usage(): 63 print("""Usage: 64cinnamon-settings [MODULE [OPTIONS]] [HELP_OPTION] 65 66Help option (HELP_OPTION): 67 -h, --help Displays help message (e.g. this message). 68 69Module options: 70 -t, --tab Opens the specified tab (see list in manpage) of 71 module settings. 72 73 -s, --sort xlets modules option. 74 xlets are 'applets', 'desklets', 'extensions' 75 and 'themes'. 76 Sorts the xlets by: 77 'name' or 0 78 'score' or 1 (by default) 79 'date' or 2 80 'installed' or 3 81 'update' or 4 82Example: 83 $ cinnamon-settings applets -t download -s date 84 85For complete description and examples, see the manpage: cinnamon-settings(1) 86 """) 87 exit(2) 88 89opts = [] 90try: 91 if len(sys.argv) > 1: 92 opts = getopt.getopt(sys.argv[1:], "h", ["help"])[0] 93except getopt.GetoptError: 94 pass 95 96for opt, arg in opts: 97 if opt in ("-h", "--help"): 98 usage() 99 break 100 101opts = [] 102try: 103 if len(sys.argv) > 2: 104 opts = getopt.getopt(sys.argv[2:], "t:s:", ["tab=", "sort="])[0] 105except getopt.GetoptError: 106 pass 107 108optional_args = False 109for opt, arg in opts: 110 if opt in ("-t", "--tab", "-s", "--sort"): 111 optional_args = True 112 break 113 114if len(sys.argv) > 1: 115 module = sys.argv[1] 116 if module in ("applets", "desklets", "extensions") and len(sys.argv) > 2 and sys.argv[2][0:5] != "panel": 117 if not optional_args: 118 os.execvp("/usr/local/share/cinnamon/cinnamon-settings/xlet-settings.py", (" ", module[0:-1]) + tuple(sys.argv[2:])) 119 elif os.path.exists("/usr/local/share/cinnamon/cinnamon-settings/modules/cs_%s.py" % module): 120 os.execvp("/usr/local/share/cinnamon/cinnamon-settings/cinnamon-settings.py", (" ",) + tuple(sys.argv[1:])) 121 elif os.path.exists("/usr/local/share/cinnamon/cinnamon-settings/modules/cs_%s.py" % module): 122 os.execvp("/usr/local/share/cinnamon/cinnamon-settings/cinnamon-settings.py", (" ",) + tuple(sys.argv[1:])) 123 elif os.path.exists("/usr/local/bin/cinnamon-control-center"): 124 os.execvp("/usr/local/share/cinnamon/cinnamon-settings/cinnamon-settings.py", (" ",) + tuple(sys.argv[1:])) 125 elif os.path.exists("/usr/local/bin/gnome-control-center"): 126 print ("Unknown module %s, calling gnome-control-center" % module) 127 os.execvp("gnome-control-center", (" ",) + tuple(sys.argv[1:])) 128 else: 129 print ("Unknown module %s" % module) 130 os.execvp("/usr/local/share/cinnamon/cinnamon-settings/cinnamon-settings.py", (" ",) + tuple(sys.argv[1:])) 131else: 132 os.execvp("/usr/local/share/cinnamon/cinnamon-settings/cinnamon-settings.py", (" ",) + tuple(sys.argv[1:])) 133