File: theme-switch-helper.py

package info (click to toggle)
update-manager 0.68.debian-7
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 6,796 kB
  • ctags: 814
  • sloc: python: 5,646; xml: 1,571; sh: 433; makefile: 356; ansic: 264
file content (49 lines) | stat: -rwxr-xr-x 1,755 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python
#
# This is a helper for the ReleaseUpgrader. it will need to be called
# like this:
# os.system("sudo -u %s theme-switch-helper.py", os.environ["SUDO_USER"])
# to make sure that it is run in the users session
# 

import gconf
import subprocess
from optparse import OptionParser


parser = OptionParser()
parser.add_option("-g", "--get", action="store_true", dest="get",
                  help="get the current gnome/gtk theme settings")
parser.add_option("-s", "--set", dest="set", 
                  help="set the current gnome/gtk theme settings")
parser.add_option("-d", "--defaults", dest="defaults", action="store_true",
                  help="set gtk/gnome settings to save defaults")
(options, args) = parser.parse_args()

client = gconf.client_get_default()

if options.get:
    # get current settings
    gtk_theme = client.get_string("/desktop/gnome/interface/gtk_theme")
    icon_theme = client.get_string("/desktop/gnome/interface/icon_theme")
    metacity_theme = client.get_string("/apps/metacity/general/theme")
    print gtk_theme
    print icon_theme
    print metacity_theme

if options.defaults:
    # set to save defaults
    client.set_string("/desktop/gnome/interface/gtk_theme","Human")
    client.set_string("/desktop/gnome/interface/icon_theme","Human")
    client.set_string("/apps/metacity/general/theme","Human")

if options.set:
    (gtk_theme, icon_theme, metacity_theme) = open(options.set).read().strip().split("\n")
    print gtk_theme
    print icon_theme
    print metacity_theme
    client.set_string("/desktop/gnome/interface/gtk_theme", gtk_theme)
    client.set_string("/desktop/gnome/interface/icon_theme", icon_theme)
    client.set_string("/apps/metacity/general/theme", metacity_theme)