Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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