Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2028 - (hide annotations) (download)
Mon Aug 13 11:37:22 2012 UTC (11 years, 8 months ago) by niro
File size: 4439 byte(s)
-fixed a typo
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 2016 local file
14     local ver
15 niro 1248
16 niro 1253 MMINCLUDE="${MCORE_CONFIG_PATH}/fluxbox/mcore-menu-include"
17 niro 2013 CONFIG="${MROOT}/${MMINCLUDE}"
18 niro 1253 clearconfig
19 niro 2015 for file in $(find ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu -type f)
20 niro 1248 do
21 niro 2013 [[ ! -z ${MROOT} ]] && file=$(echo ${file} | sed "s:${MROOT}::")
22 niro 1253 addconfig "[include] (${file})"
23 niro 1248 done
24    
25     # rebuild the user menu too atm
26 niro 2013 CONFIG="${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/menu"
27     if [[ ! -d ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox ]]
28 niro 1253 then
29 niro 2013 install -o ${MCORE_UNPRIV_USER} -o ${MCORE_UNPRIV_GROUP} -d ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox
30 niro 1253 fi
31 niro 1248
32 niro 1253 # fluxbox menu header
33     clearconfig
34 niro 2016 ver="$(< ${MROOT}/etc/mageversion)"
35     addconfig "[begin] (${MCORE_DISTRIBUTION}-${ver} #${MCORE_SERIAL})"
36 niro 1248
37     # add a newline (maybe there is no crlf in the header)
38 niro 1253 addconfig
39 niro 1248
40 niro 1253 # our specific menu include
41     addconfig "[include] (${MMINCLUDE})"
42 niro 1248
43     # fluxbox menu footer
44 niro 1642 addconfig '[separator]'
45     addconfig '[exit] (Abmelden)'
46 niro 1327 addconfig '[exec] (Neustarten) {sudo /sbin/reboot}'
47     addconfig '[exec] (Herunterfahren) {sudo /sbin/halt}'
48 niro 1253 addconfig '[end]'
49 niro 1248
50     # add a newline (maybe there is no crlf in the footer)
51 niro 1253 addconfig
52 niro 1248 }
53    
54 niro 1919 helper_rebuild_fluxbox_autostart()
55     {
56     local CONFIG
57    
58 niro 2013 CONFIG="${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/apps"
59 niro 1919 clearconfig
60 niro 2015 for file in $(find ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/autostart -type f)
61 niro 1919 do
62     addconfig "$(< ${file})"
63     done
64    
65     # add a newline (maybe there is no crlf in the footer)
66     addconfig
67     }
68    
69 niro 1257 help_fluxbox_menuitem()
70 niro 1248 {
71 niro 1257 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 niro 1248 }
87    
88 niro 1257 # set_fluxbox_menuitem $name $exec $workdir $icon
89     set_fluxbox_menuitem()
90 niro 1248 {
91 niro 1257 local action="$1"
92     local name="$2"
93     local exec="$3"
94     local workdir="$4"
95     local icon="$5"
96 niro 1253 local CONFIG
97 niro 1248
98 niro 1257 [[ -z ${action} ]] && help_fluxbox_menuitem && return 1
99 niro 1248
100 niro 1257 case "${action}" in
101     add)
102     [[ -z ${name} ]] && help_fluxbox_menuitem && return 1
103     [[ -z ${exec} ]] && help_fluxbox_menuitem && return 1
104 niro 2013 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/${name}"
105 niro 1257 clearconfig
106     addconfig "[exec] (${name}) {${exec}}"
107     ;;
108     del)
109 niro 2013 if [[ -f ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]]
110 niro 1257 then
111 niro 2013 rm ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/"${name}"
112 niro 1257 elif [[ -z ${name} ]]
113     then
114     # delete all items
115 niro 2027 find ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu -type f | xargs --no-run-if-empty rm
116 niro 1257 fi
117     ;;
118     *)
119     help_fluxbox_menuitem && return 1
120     ;;
121     esac
122 niro 1253
123 niro 1248 # rebuild the menu now
124 niro 1253 helper_rebuild_fluxbox_menu
125 niro 1248 }
126    
127 niro 1257 # get_fluxbox_menuitem
128     get_fluxbox_menuitem()
129 niro 1248 {
130 niro 2014 list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu
131 niro 1248 }
132    
133 niro 1257 help_fluxbox_theme()
134 niro 1248 {
135 niro 1257 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 niro 1248
145 niro 1257 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 niro 1248 then
155 niro 1257 x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'"
156     else
157 niro 2028 eecho "Theme '${theme}' does not exist!"
158 niro 1248 fi
159 niro 1257 }
160 niro 1248
161 niro 1257 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 niro 2014 list_files_in_directory -type d -mindepth 1 -maxdepth 1 ${MROOT}/${stylesdir}
173 niro 1257 ;;
174    
175     current)
176 niro 2013 value=$(grep -i '^session.stylefile' ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/init | sed 's:.*/\(.*\):\1:')
177 niro 1642 rvecho "${value}"
178 niro 1257 ;;
179     *) help_fluxbox_theme && return 1 ;;
180     esac
181 niro 1248 }