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