Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2013 - (show annotations) (download)
Mon Aug 13 10:00:31 2012 UTC (11 years, 9 months ago) by niro
File size: 4501 byte(s)
-support $MROOT variable
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
14 MMINCLUDE="${MCORE_CONFIG_PATH}/fluxbox/mcore-menu-include"
15 CONFIG="${MROOT}/${MMINCLUDE}"
16 clearconfig
17
18 for file in ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/*
19 do
20 [[ ! -z ${MROOT} ]] && file=$(echo ${file} | sed "s:${MROOT}::")
21 addconfig "[include] (${file})"
22 done
23
24 # rebuild the user menu too atm
25 CONFIG="${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/menu"
26 if [[ ! -d ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox ]]
27 then
28 install -o ${MCORE_UNPRIV_USER} -o ${MCORE_UNPRIV_GROUP} -d ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox
29 fi
30
31 # fluxbox menu header
32 clearconfig
33 local ver="$(< ${MROOT}/etc/mageversion)"
34 addconfig "[begin] (mCore-${ver} #${MCORE_SERIAL})"
35
36 # add a newline (maybe there is no crlf in the header)
37 addconfig
38
39 # our specific menu include
40 addconfig "[include] (${MMINCLUDE})"
41
42 # fluxbox menu footer
43 addconfig '[separator]'
44 addconfig '[exit] (Abmelden)'
45 addconfig '[exec] (Neustarten) {sudo /sbin/reboot}'
46 addconfig '[exec] (Herunterfahren) {sudo /sbin/halt}'
47 addconfig '[end]'
48
49 # add a newline (maybe there is no crlf in the footer)
50 addconfig
51 }
52
53 helper_rebuild_fluxbox_autostart()
54 {
55 local CONFIG
56
57 CONFIG="${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/apps"
58 clearconfig
59 for file in ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/autostart/*
60 do
61 addconfig "$(< ${file})"
62 done
63
64 # add a newline (maybe there is no crlf in the footer)
65 addconfig
66 }
67
68 help_fluxbox_menuitem()
69 {
70 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 }
86
87 # set_fluxbox_menuitem $name $exec $workdir $icon
88 set_fluxbox_menuitem()
89 {
90 local action="$1"
91 local name="$2"
92 local exec="$3"
93 local workdir="$4"
94 local icon="$5"
95 local CONFIG
96
97 [[ -z ${action} ]] && help_fluxbox_menuitem && return 1
98
99 case "${action}" in
100 add)
101 [[ -z ${name} ]] && help_fluxbox_menuitem && return 1
102 [[ -z ${exec} ]] && help_fluxbox_menuitem && return 1
103 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/${name}"
104 clearconfig
105 addconfig "[exec] (${name}) {${exec}}"
106 ;;
107 del)
108 if [[ -f ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]]
109 then
110 rm ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/"${name}"
111 elif [[ -z ${name} ]]
112 then
113 # delete all items
114 rm ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/*
115 fi
116 ;;
117 *)
118 help_fluxbox_menuitem && return 1
119 ;;
120 esac
121
122 # rebuild the menu now
123 helper_rebuild_fluxbox_menu
124 }
125
126 # get_fluxbox_menuitem
127 get_fluxbox_menuitem()
128 {
129 local i
130 local item
131
132 for i in $(find ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu -type f | sort)
133 do
134 item="${item} $(basename ${i})"
135 done
136
137 rvecho "${item}"
138 }
139
140 help_fluxbox_theme()
141 {
142 mecho "get fluxbox.theme [method]"
143 mecho " Displays current installed or system-wide available themes."
144 mecho " Methods:"
145 mecho " system - shows systemwide available themes"
146 mecho " current - shows current selected theme"
147 mecho
148 mecho "set fluxbox.theme [theme]"
149 mecho " Sets a default theme for fluxbox."
150 }
151
152 set_fluxbox_theme()
153 {
154 local theme="$1"
155 local stylesdir="/usr/share/fluxbox/styles"
156
157 [[ -z ${theme} ]] && help_fluxbox_theme && return 1
158 [[ ! -x $(which fluxbox-remote) ]] && eecho "fluxbox-remote missing! Aborted" && return 1
159
160 if [[ -e ${stylesdir}/${theme} ]]
161 then
162 x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'"
163 else
164 eechoe "Theme '${theme}' does not exist!"
165 fi
166 }
167
168 get_fluxbox_theme()
169 {
170 local method="$1"
171 local stylesdir="/usr/share/fluxbox/styles"
172 local value
173 local i
174
175 [[ -z ${method} ]] && help_fluxbox_theme && return 1
176
177 case "${method}" in
178 system)
179 for i in $(find ${MROOT}/${stylesdir} -mindepth 1 -maxdepth 1 | sort)
180 do
181 value="${value} $(basename ${i})"
182 done
183 rvecho "${value}"
184 ;;
185
186 current)
187 value=$(grep -i '^session.stylefile' ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/init | sed 's:.*/\(.*\):\1:')
188 rvecho "${value}"
189 ;;
190 *) help_fluxbox_theme && return 1 ;;
191 esac
192 }