16
12
# This program is distributed in the hope that it will be useful,
17
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# ERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
15
# GNU General Public License for more details.
20
16
# http://www.gnu.org/licenses/licenses.html#GPL
22
### We assume the name of this applet is "demo_bash"
23
### This Python script (demo_bash) should be placed in a folder alongside with 3 files :
24
### demo_bash.conf (the default config file), "icon" (the default icon of the applet) , "preview" (a preview of this applet) and demo_bash.sh (the script in bash, where you will place your code)
35
from dbus.mainloop.glib import DBusGMainLoop
37
# get our applet on the bus
38
app_folder = os.path.dirname(sys.argv[0])
39
applet_name = os.path.basename(os.path.abspath("."))
40
applet_path = "/org/cairodock/CairoDock/"+applet_name
41
DBusGMainLoop(set_as_default=True)
42
bus = dbus.SessionBus()
44
applet_object = bus.get_object("org.cairodock.CairoDock", applet_path)
45
except dbus.DBusException:
46
print ">>> module '"+applet_name+"' can't be found on the bus, exit."
48
myIcon = dbus.Interface(applet_object, "org.cairodock.CairoDock.applet")
50
### we'll have a sub-dock, so we also get the sub-icons object ###
51
#sub_icons_object = bus.get_object("org.cairodock.CairoDock", applet_path+"/sub_icons")
52
#mySubIcons = dbus.Interface(sub_icons_object, "org.cairodock.CairoDock.subapplet")
55
def action_on_click(iState):
56
return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_click").read().rstrip()
57
print return_from_bash
59
def action_on_middle_click():
60
return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_middle_click").read().rstrip()
61
print return_from_bash
63
def action_on_scroll_icon(bUpOrDown):
65
return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_scroll_icon 0").read().rstrip()
66
print return_from_bash
68
return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_scroll_icon 1").read().rstrip()
69
print return_from_bash
71
def action_on_drop_data(sDataName):
72
return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_drop_data " + sDataName).read().rstrip()
73
print return_from_bash
76
return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_init").read().rstrip()
77
print return_from_bash
80
return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_stop").read().rstrip()
81
print return_from_bash
83
def action_on_reload(bConfigHasChanged):
85
return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_reload").read().rstrip()
86
print return_from_bash
88
def action_on_build_menu():
89
return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_build_menu").read().rstrip()
90
print return_from_bash
92
def action_on_menu_select(iNumEntry):
93
return_from_bash = os.popen("cd " + app_folder + " && ./" + applet_name + ".sh " + " action_on_menu_select " + str(iNumEntry)).read().rstrip()
94
print return_from_bash
98
# register to the notifications on our applet
99
myIcon.connect_to_signal("on_click", action_on_click)
100
myIcon.connect_to_signal("on_middle_click", action_on_middle_click)
101
myIcon.connect_to_signal("on_scroll", action_on_scroll_icon)
102
myIcon.connect_to_signal("on_drop_data", action_on_drop_data)
103
myIcon.connect_to_signal("on_init_module", action_on_init)
104
myIcon.connect_to_signal("on_stop_module", action_on_stop)
105
myIcon.connect_to_signal("on_reload_module", action_on_reload)
106
myIcon.connect_to_signal("on_build_menu", action_on_build_menu)
107
myIcon.connect_to_signal("on_menu_select", action_on_menu_select)
18
# The name of this applet is "demo_bash"; it is placed in a folder named "demo_bash", with a file named "auto-load.conf" which describes it.
19
# Copy this folder into ~/.config/cairo-dock/third-party to let the dock register it automatically.
20
# In the folder we have :
21
# - "demo_bash" : this python script, without extension
22
# - "demo_bash.sh" : the script in bash, where you actually place your code
23
# - "demo_bash.conf" : the config file of the applet
24
# - "auto-load.conf" : the file describing the applet
25
# - "icon" : the default icon of the applet (optionnal)
26
# - "preview" : a preview of this applet (optionnal)
28
from CDBashApplet import CDBashApplet
110
30
if __name__ == '__main__':