-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppRun
executable file
·114 lines (92 loc) · 2.9 KB
/
AppRun
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python
import findrox; findrox.version(1, 9, 6)
import rox, os
from rox import g
import rox.settings
class XSetting:
def __init__(self, name, settings):
self.settings = settings
self.name = name
try:
self.value = int(settings.GetSetting(self.name)[1])
except:
self.value = 1000
def SetInt(self, value):
self.settings.SetInt(self.name, value)
self.value = value
class OverallPseudoSetting:
def __init__(self, r, g, b):
self.r = r
self.g = g
self.b = b
self.value = (r.value + g.value + b.value) / 3
def SetInt(self, value):
self.value = value
self.r.SetInt(value)
self.g.SetInt(value)
self.b.SetInt(value)
rsetting, gsetting, bsetting, osetting = [None, None, None, None]
if os.environ.get('ROX_SESSION_ENVIRONMENT') != None:
try:
settings = rox.settings.get_xsettings()
rsetting = XSetting("ROX/RGamma", settings)
gsetting = XSetting("ROX/GGamma", settings)
bsetting = XSetting("ROX/BGamma", settings)
osetting = OverallPseudoSetting(rsetting, gsetting, bsetting)
except:
rox.alert('Unable to use ROX-Session settings')
sizes = g.SizeGroup(g.SIZE_GROUP_HORIZONTAL)
class Slider(g.HBox):
def __init__(self, title, name, setting, default = 1.0):
if setting:
default = float(setting.value) / 1000.0
self.setting = setting
self.gname = name
g.HBox.__init__(self, False, 2)
label = g.Label(title + ': ')
label.set_alignment(1.0, 0.5)
sizes.add_widget(label)
self.pack_start(label, False, True, 0)
self.adj = g.Adjustment(default, 0.1, 5)
slider = g.HScale(self.adj)
slider.set_value_pos(g.POS_RIGHT)
self.pack_start(slider, True, True, 0)
self.adj.connect('value-changed', self.change)
def change(self, adj):
if self.setting:
self.setting.SetInt(int(adj.value * 1000))
else:
os.system('xgamma -q -%s %f' % (self.gname, adj.value))
box = rox.Dialog()
box.set_position(g.WIN_POS_MOUSE)
box.set_has_separator(False)
box.add_button(g.STOCK_CLOSE, g.RESPONSE_CANCEL)
toggle = g.CheckButton('Set red, green and blue separately')
box.vbox.pack_start(toggle, False, True, 0)
current = os.popen('xgamma 2>&1').read()
red, green, blue = [float(c.split()[-1]) for c in current.split(',')]
all = (red + green + blue) / 3
toggle.set_active(not (red == green == blue))
overall = Slider('Overall', 'gamma', osetting, all)
red_slider = Slider('Red', 'rgamma', rsetting, red)
green_slider = Slider('Green', 'ggamma', gsetting, green)
blue_slider = Slider('Blue', 'bgamma', bsetting, blue)
box.vbox.pack_start(overall)
rgb = g.VBox(True, 0)
box.vbox.pack_start(rgb)
rgb.pack_start(red_slider)
rgb.pack_start(green_slider)
rgb.pack_start(blue_slider)
def shade():
sep = toggle.get_active()
overall.set_sensitive(not sep)
rgb.set_sensitive(sep)
if sep:
for s in (red_slider, green_slider, blue_slider):
s.adj.emit('value-changed')
else:
overall.adj.emit('value-changed')
shade()
toggle.connect('toggled', lambda x: shade())
box.vbox.show_all()
box.run()