Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/daemon/client/include/fluxbox.client.class

Parent Directory Parent Directory | Revision Log Revision Log


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