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