Annotation of /mcore-src/trunk/mcore-tools/daemon/client/include/fluxbox.client.class
Parent Directory | Revision Log
Revision 1642 -
(hide annotations)
(download)
Thu Mar 10 18:12:24 2011 UTC (13 years, 2 months ago) by niro
File size: 4028 byte(s)
Thu Mar 10 18:12:24 2011 UTC (13 years, 2 months ago) by niro
File size: 4028 byte(s)
-use [separator] in fluxbox menu instead of [nop] (____) -use rvecho() for function retvals
1 | niro | 1248 | # $Id$ |
2 | |||
3 | niro | 1257 | # todo wallpaper? |
4 | |||
5 | niro | 1248 | # what does this plugin provide? |
6 | provide fluxbox | ||
7 | |||
8 | # helper | ||
9 | niro | 1253 | helper_rebuild_fluxbox_menu() |
10 | niro | 1248 | { |
11 | niro | 1253 | local MMINCLUDE |
12 | local CONFIG | ||
13 | niro | 1248 | |
14 | niro | 1253 | MMINCLUDE="${MCORE_CONFIG_PATH}/fluxbox/mcore-menu-include" |
15 | CONFIG="${MMINCLUDE}" | ||
16 | clearconfig | ||
17 | |||
18 | for file in ${MCORE_CONFIG_PATH}/fluxbox/menu/* | ||
19 | niro | 1248 | do |
20 | niro | 1253 | addconfig "[include] (${file})" |
21 | niro | 1248 | done |
22 | |||
23 | # rebuild the user menu too atm | ||
24 | niro | 1253 | CONFIG="${MCORE_UNPRIV_HOME}/.fluxbox/menu" |
25 | if [[ ! -d ${MCORE_UNPRIV_HOME}/.fluxbox ]] | ||
26 | then | ||
27 | install -o ${MCORE_UNPRIV_USER} -o ${MCORE_UNPRIV_GROUP} -d ${MCORE_UNPRIV_HOME}/.fluxbox | ||
28 | fi | ||
29 | niro | 1248 | |
30 | niro | 1253 | # fluxbox menu header |
31 | clearconfig | ||
32 | niro | 1248 | local ver="$(< /etc/mageversion)" |
33 | niro | 1253 | addconfig "[begin] (mCore-${ver} #${MCORE_SERIAL})" |
34 | niro | 1248 | |
35 | # add a newline (maybe there is no crlf in the header) | ||
36 | niro | 1253 | addconfig |
37 | niro | 1248 | |
38 | niro | 1253 | # our specific menu include |
39 | addconfig "[include] (${MMINCLUDE})" | ||
40 | niro | 1248 | |
41 | # fluxbox menu footer | ||
42 | niro | 1642 | addconfig '[separator]' |
43 | addconfig '[exit] (Abmelden)' | ||
44 | niro | 1327 | addconfig '[exec] (Neustarten) {sudo /sbin/reboot}' |
45 | addconfig '[exec] (Herunterfahren) {sudo /sbin/halt}' | ||
46 | niro | 1253 | addconfig '[end]' |
47 | niro | 1248 | |
48 | # add a newline (maybe there is no crlf in the footer) | ||
49 | niro | 1253 | addconfig |
50 | niro | 1248 | } |
51 | |||
52 | niro | 1257 | help_fluxbox_menuitem() |
53 | niro | 1248 | { |
54 | niro | 1257 | mecho "get fluxbox.menuitem" |
55 | mecho " Shows all custom added menuitems of fluxbox." | ||
56 | mecho | ||
57 | mecho "set fluxbox.menuitem [action] [name] [exec] [workdir] [icon]" | ||
58 | mecho " Adds or deletes a fluxbox menu entry." | ||
59 | mecho " Actions:" | ||
60 | mecho " add - adds a menuitem" | ||
61 | mecho " del - deletes a menuitem" | ||
62 | mecho | ||
63 | mecho " name - menu entry name" | ||
64 | mecho " exec - executable to start" | ||
65 | mecho " workdir - working directory for the executable - optional" | ||
66 | mecho " icon - pixmap icon of the entry - optional" | ||
67 | mecho | ||
68 | mecho " If no [name] given, all entries will be deleted." | ||
69 | niro | 1248 | } |
70 | |||
71 | niro | 1257 | # set_fluxbox_menuitem $name $exec $workdir $icon |
72 | set_fluxbox_menuitem() | ||
73 | niro | 1248 | { |
74 | niro | 1257 | local action="$1" |
75 | local name="$2" | ||
76 | local exec="$3" | ||
77 | local workdir="$4" | ||
78 | local icon="$5" | ||
79 | niro | 1253 | local CONFIG |
80 | niro | 1248 | |
81 | niro | 1257 | [[ -z ${action} ]] && help_fluxbox_menuitem && return 1 |
82 | niro | 1248 | |
83 | niro | 1257 | case "${action}" in |
84 | add) | ||
85 | [[ -z ${name} ]] && help_fluxbox_menuitem && return 1 | ||
86 | [[ -z ${exec} ]] && help_fluxbox_menuitem && return 1 | ||
87 | CONFIG="${MCORE_CONFIG_PATH}/fluxbox/menu/${name}" | ||
88 | clearconfig | ||
89 | addconfig "[exec] (${name}) {${exec}}" | ||
90 | ;; | ||
91 | del) | ||
92 | if [[ -f ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]] | ||
93 | then | ||
94 | rm ${MCORE_CONFIG_PATH}/fluxbox/menu/"${name}" | ||
95 | elif [[ -z ${name} ]] | ||
96 | then | ||
97 | # delete all items | ||
98 | rm ${MCORE_CONFIG_PATH}/fluxbox/menu/* | ||
99 | fi | ||
100 | ;; | ||
101 | *) | ||
102 | help_fluxbox_menuitem && return 1 | ||
103 | ;; | ||
104 | esac | ||
105 | niro | 1253 | |
106 | niro | 1248 | # rebuild the menu now |
107 | niro | 1253 | helper_rebuild_fluxbox_menu |
108 | niro | 1248 | } |
109 | |||
110 | niro | 1257 | # get_fluxbox_menuitem |
111 | get_fluxbox_menuitem() | ||
112 | niro | 1248 | { |
113 | niro | 1257 | local i |
114 | local item | ||
115 | |||
116 | for i in $(find ${MCORE_CONFIG_PATH}/fluxbox/menu -type f | sort) | ||
117 | do | ||
118 | item="${item} $(basename ${i})" | ||
119 | done | ||
120 | |||
121 | niro | 1642 | rvecho "${item}" |
122 | niro | 1248 | } |
123 | |||
124 | niro | 1257 | help_fluxbox_theme() |
125 | niro | 1248 | { |
126 | niro | 1257 | mecho "get fluxbox.theme [method]" |
127 | mecho " Displays current installed or system-wide available themes." | ||
128 | mecho " Methods:" | ||
129 | mecho " system - shows systemwide available themes" | ||
130 | mecho " current - shows current selected theme" | ||
131 | mecho | ||
132 | mecho "set fluxbox.theme [theme]" | ||
133 | mecho " Sets a default theme for fluxbox." | ||
134 | } | ||
135 | niro | 1248 | |
136 | niro | 1257 | set_fluxbox_theme() |
137 | { | ||
138 | local theme="$1" | ||
139 | local stylesdir="/usr/share/fluxbox/styles" | ||
140 | |||
141 | [[ -z ${theme} ]] && help_fluxbox_theme && return 1 | ||
142 | [[ ! -x $(which fluxbox-remote) ]] && eecho "fluxbox-remote missing! Aborted" && return 1 | ||
143 | |||
144 | if [[ -e ${stylesdir}/${theme} ]] | ||
145 | niro | 1248 | then |
146 | niro | 1257 | x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'" |
147 | else | ||
148 | eechoe "Theme '${theme}' does not exist!" | ||
149 | niro | 1248 | fi |
150 | niro | 1257 | } |
151 | niro | 1248 | |
152 | niro | 1257 | get_fluxbox_theme() |
153 | { | ||
154 | local method="$1" | ||
155 | local stylesdir="/usr/share/fluxbox/styles" | ||
156 | local value | ||
157 | local i | ||
158 | |||
159 | [[ -z ${method} ]] && help_fluxbox_theme && return 1 | ||
160 | |||
161 | case "${method}" in | ||
162 | system) | ||
163 | for i in $(find ${stylesdir} -mindepth 1 -maxdepth 1 | sort) | ||
164 | do | ||
165 | value="${value} $(basename ${i})" | ||
166 | done | ||
167 | niro | 1642 | rvecho "${value}" |
168 | niro | 1257 | ;; |
169 | |||
170 | current) | ||
171 | value=$(grep -i '^session.stylefile' ${MCORE_UNPRIV_HOME}/.fluxbox/init | sed 's:.*/\(.*\):\1:') | ||
172 | niro | 1642 | rvecho "${value}" |
173 | niro | 1257 | ;; |
174 | *) help_fluxbox_theme && return 1 ;; | ||
175 | esac | ||
176 | niro | 1248 | } |