2
# -*- coding: utf-8 -*-
5
# Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd
6
# This program is free software: you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License version 3, as published
8
# by the Free Software Foundation.
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranties of
12
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13
# PURPOSE. See the GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License along
16
# with this program. If not, see <http://www.gnu.org/licenses/>.
21
from compizsettings import CompizSetting
24
'''if compiz: key is icon_size; else if gsettins: key is icon-size'''
28
self.desktop = os.getenv('XDG_CURRENT_DESKTOP')
29
if self.desktop is None:
30
self.desktop = os.getenv('XDG_SESSION_DESKTOP')
31
# self.setting = CompizSetting("%s.%s" % (name, key))
33
# ---------------launcher---------------
34
# -----------------默认值-----------------
36
def get_default_schema_value(self, name, key):
37
compizsetting = CompizSetting("%s.%s" % (name, key))
38
return compizsetting.get_schema_value()
40
# Set Default Value min=32, max=64, step=16, key="unityshell.icon_size"
41
#def set_default_schema_value(self, key, name, type, value):
42
def set_default_schema_value(self, key, type, value):
43
#default_value = self.get_default_schema_value(name, key)
44
#if default_value is not None:
45
return gsettings.set('org.compiz.unityshell',
46
'/org/compiz/profiles/unity/plugins/unityshell/',
49
# raise NotImplemented
51
# launcher auto hide mode, True/False
52
def set_launcher_autohide(self, flag):
53
return gsettings.set('org.compiz.unityshell',
54
'/org/compiz/profiles/unity/plugins/unityshell/',
58
# get launcher auto hide mode
59
def get_launcher_autohide(self):
61
value = gsettings.get('org.compiz.unityshell',
62
'/org/compiz/profiles/unity/plugins/unityshell/',
63
'launcher-hide-mode', 'int')
73
# launcher icon size 32-64
74
def set_launcher_icon_size(self, size):
75
return gsettings.set('org.compiz.unityshell',
76
'/org/compiz/profiles/unity/plugins/unityshell/',
80
# get launcher icon size
81
def get_launcher_icon_size(self):
83
return gsettings.get('org.compiz.unityshell',
84
'/org/compiz/profiles/unity/plugins/unityshell/',
89
# launcher 'show desktop' icon True/False
90
def set_launcher_have_showdesktopicon(self, flag):
91
launcher = gsettings.get_schema('com.canonical.Unity.Launcher')
92
icons = launcher.get_strv('favorites')
93
desktop = 'unity://desktop-icon'
95
if desktop not in icons:
97
launcher.set_strv('favorites', icons)
100
icons.remove(desktop)
101
launcher.set_strv('favorites', icons)
103
# get is launcher have 'show desktop' icon
104
def get_launcher_have_showdesktopicon(self):
105
launcher = gsettings.get_schema('com.canonical.Unity.Launcher')
106
icons = launcher.get_strv('favorites')
107
desktop = 'unity://desktop-icon'
113
def get_default_launcher_have_showdesktopicon(self):
114
return self.get_launcher_have_showdesktopicon()
116
def set_default_launcher_have_showdesktopicon(self):
117
self.set_launcher_have_showdesktopicon(True)
123
def get_launcher_transparency(self):
125
return gsettings.get('org.compiz.unityshell',
126
'/org/compiz/profiles/unity/plugins/unityshell/',
127
'launcher-opacity', 'double')
131
# 'min' : 0.2, # TODO : Check these min max. Most prolly wrong.
132
# 'max' : 1.0, # But fine since they are ignored anyway.
133
# 'ticks' : [(0.666, Gtk.PositionType.BOTTOM, None)]
134
def set_launcher_transparency(self, opacity):
135
return gsettings.set('org.compiz.unityshell',
136
'/org/compiz/profiles/unity/plugins/unityshell/',
141
def get_all_launcher_icon_colourings(self):
142
# return ['0:0', '1:1', '2:2', '3:3', '4:4']
143
return ['all programs', 'only run app', 'no coloring', 'edge coloring', 'each workspace alternating coloring']
145
def get_launcher_icon_colouring(self):
147
return gsettings.get('org.compiz.unityshell',
148
'/org/compiz/profiles/unity/plugins/unityshell/',
149
'backlight-mode', 'int')
153
# 'map' : {0:0,1:1,2:2,3:3,4:4} 0:所有程序,1:仅打开的应用程序,2:不着色,3:边缘着色,4:每个工作区交替着色
154
def set_launcher_icon_colouring(self, colouring):
155
return gsettings.set('org.compiz.unityshell',
156
'/org/compiz/profiles/unity/plugins/unityshell/',
160
def get_all_launcher_position(self):
161
return ['Left', 'Bottom']
163
def get_current_launcher_position(self):
164
return gsettings.get('com.canonical.Unity.Launcher',
169
def set_launcher_position(self, position):
170
return gsettings.set('com.canonical.Unity.Launcher',
176
def get_dash_blur_experimental(self):
178
return gsettings.get('org.compiz.unityshell',
179
'/org/compiz/profiles/unity/plugins/unityshell/',
180
'dash-blur-experimental', 'int')
184
# 活动模糊smart: 2 静态模糊static:1 非模糊0
185
def set_dash_blur_experimental(self, blur):
186
return gsettings.set('org.compiz.unityshell',
187
'/org/compiz/profiles/unity/plugins/unityshell/',
188
'dash-blur-experimental',
192
def get_panel_transparency(self):
194
return gsettings.get('org.compiz.unityshell',
195
'/org/compiz/profiles/unity/plugins/unityshell/',
196
'panel-opacity', 'double')
200
# 'min' : 0.2, # TODO : Check these min max. Most prolly wrong.
201
# 'max' : 8.0, # But fine since they are ignored anyway.
202
# 'ticks' : [(0.666, Gtk.PositionType.BOTTOM, None)]
203
def set_panel_transparency(self, opacity):
204
return gsettings.set('org.compiz.unityshell',
205
'/org/compiz/profiles/unity/plugins/unityshell/',
210
def get_all_time_format(self):
211
return ['locale-default', '12-hour' , '24-hour', 'custom']
213
def get_time_format(self):
214
# if self.desktop == "mate":
215
# return gsettings.get('org.mate.panel',
216
# '/org/mate/panel/objects/clock/prefs/',
220
return gsettings.get('com.canonical.indicator.datetime',
225
def set_time_format(self, format):
226
# if self.desktop == "mate":
227
# return gsettings.set('org.mate.panel',
228
# '/org/mate/panel/objects/clock/prefs/',
232
return gsettings.set('com.canonical.indicator.datetime',
237
def get_show_seconds(self):
238
return gsettings.get('com.canonical.indicator.datetime',
243
def set_show_seconds(self, flag):
244
return gsettings.set('com.canonical.indicator.datetime',
250
def get_show_week(self):
251
return gsettings.get('com.canonical.indicator.datetime',
256
def set_show_week(self, flag):
257
return gsettings.set('com.canonical.indicator.datetime',
263
def get_show_date(self):
264
return gsettings.get('com.canonical.indicator.datetime',
269
def set_show_date(self, flag):
270
return gsettings.set('com.canonical.indicator.datetime',
276
# present:电源总是可见 charge:当机器充电/放电时可见 never:总是不可见
277
def get_all_power_icon_policy(self):
278
return ['present', 'charge', 'never']
280
def get_power_icon_policy(self):
281
return gsettings.get('com.canonical.indicator.power',
286
def set_power_icon_policy(self, flag):
287
return gsettings.set('com.canonical.indicator.power',
293
def get_show_power_time(self):
294
return gsettings.get('com.canonical.indicator.power',
299
def set_show_power_time(self, flag):
300
return gsettings.set('com.canonical.indicator.power',
306
def get_show_power_percentage(self):
307
return gsettings.get('com.canonical.indicator.power',
312
def set_show_power_percentage(self, flag):
313
return gsettings.set('com.canonical.indicator.power',
318
#-----------------mate----------------------------
319
def set_mate_panel_icon_size(self, position, size):
320
if position == "top":
321
return gsettings.set('org.mate.panel.toplevel',
322
'/org/mate/panel/toplevels/top/',
325
elif position == "bottom":
326
return gsettings.set('org.mate.panel.toplevel',
327
'/org/mate/panel/toplevels/bottom/',
333
# get launcher icon size
334
def get_mate_panel_icon_size(self, position):
335
if position == "top":
336
return gsettings.get('org.mate.panel.toplevel',
337
'/org/mate/panel/toplevels/top/',
339
elif position == "bottom":
340
return gsettings.get('org.mate.panel.toplevel',
341
'/org/mate/panel/toplevels/bottom/',
346
def set_mate_panel_autohide(self, position, flag):
347
if position == "top":
348
return gsettings.set('org.mate.panel.toplevel',
349
'/org/mate/panel/toplevels/top/',
352
elif position == "bottom":
353
return gsettings.set('org.mate.panel.toplevel',
354
'/org/mate/panel/toplevels/bottom/',
360
def get_mate_panel_autohide(self, position):
361
if position == "top":
362
return gsettings.get('org.mate.panel.toplevel',
363
'/org/mate/panel/toplevels/top/',
364
'auto-hide', 'boolean')
365
elif position == "bottom":
366
return gsettings.get('org.mate.panel.toplevel',
367
'/org/mate/panel/toplevels/bottom/',
368
'auto-hide', 'boolean')
372
def get_show_apps(self):
373
return gsettings.get('org.mate.panel.menubar',
378
def set_show_apps(self, flag):
379
return gsettings.set('org.mate.panel.menubar',
384
def get_show_desktop(self):
385
return gsettings.get('org.mate.panel.menubar',
390
def set_show_desktop(self, flag):
391
return gsettings.set('org.mate.panel.menubar',
396
def get_show_icon(self):
397
return gsettings.get('org.mate.panel.menubar',
402
def set_show_icon(self, flag):
403
return gsettings.set('org.mate.panel.menubar',
408
def get_show_places(self):
409
return gsettings.get('org.mate.panel.menubar',
414
def set_show_places(self, flag):
415
return gsettings.set('org.mate.panel.menubar',
420
if __name__ == '__main__':
422
# print uuu.get_launcher_icon_colouring()
423
# print uuu.set_launcher_icon_colouring(1)
424
print uuu.get_time_format()
425
# bb = uuu.get_default_schema_value("unityshell", "icon_size")
426
# aa = uuu.get_default_schema_value("unityshell", "launcher_hide_mode")
427
#aa = uuu.get_default_schema_value('org.gnome.desktop.media-handling', 'automount')
428
#uuu = Unity("unityshell", "icon_size")
429
#aa = uuu.get_launcher_icon_size_test()
434
#uuu.set_default_schema_value('icon-size', 'int', bb)
435
# cc = uuu.get_default_launcher_have_showdesktopicon()
438
#uuu.set_default_schema_value('launcher-hide-mode', 'int', aa)
440
#bb = uuu.get_default_launcher_icon_size()
444
#uuu.reset_default_launcher_icon_size(bb)
445
#uuu.set_launcher_icon_size(48)
446
# print uuu.get_launcher_icon_size()
447
# print uuu.get_launcher_have_showdesktopicon()
448
# uuu.set_launcher_autohide(0)
449
# print uuu.get_launcher_autohide()
450
# uuu.set_launcher_have_showdesktopicon(True)
451
# uuu.set_launcher_icon_size(48)