1 |
# $Id$ |
# $Id$ |
2 |
|
|
3 |
|
# todo wallpaper? |
4 |
|
|
5 |
# what does this plugin provide? |
# what does this plugin provide? |
6 |
provide fluxbox |
provide fluxbox |
7 |
|
|
8 |
# helper |
# helper |
9 |
helper_session_rebuild_fluxbox_menu() |
helper_rebuild_fluxbox_menu() |
10 |
{ |
{ |
11 |
:> ${SETTINGSPATH}/fluxbox/alxmenu |
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 ${SETTINGSPATH}/fluxbox/menu/* |
for file in ${MCORE_CONFIG_PATH}/fluxbox/menu/* |
19 |
do |
do |
20 |
echo "[include] (${file})" >> ${SETTINGSPATH}/fluxbox/alxmenu |
addconfig "[include] (${file})" |
21 |
done |
done |
22 |
|
|
23 |
# rebuild the user menu too atm |
# rebuild the user menu too atm |
24 |
cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu |
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 |
# now fix it with proper messages :P |
# fluxbox menu header |
31 |
|
clearconfig |
32 |
local ver="$(< /etc/mageversion)" |
local ver="$(< /etc/mageversion)" |
33 |
sed -i "s:@CHANGEME@:tinyALX-${ver} #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu |
addconfig "[begin] (mCore-${ver} #${MCORE_SERIAL})" |
34 |
|
|
35 |
# add a newline (maybe there is no crlf in the header) |
# add a newline (maybe there is no crlf in the header) |
36 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
addconfig |
37 |
|
|
38 |
# our specific include |
# our specific menu include |
39 |
echo "[include] (${SETTINGSPATH}/fluxbox/alxmenu)" >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
addconfig "[include] (${MMINCLUDE})" |
40 |
|
|
41 |
# fluxbox menu footer |
# fluxbox menu footer |
42 |
cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
addconfig '[separator]' |
43 |
|
addconfig '[exit] (Abmelden)' |
44 |
|
addconfig '[exec] (Neustarten) {sudo /sbin/reboot}' |
45 |
|
addconfig '[exec] (Herunterfahren) {sudo /sbin/halt}' |
46 |
|
addconfig '[end]' |
47 |
|
|
48 |
# add a newline (maybe there is no crlf in the footer) |
# add a newline (maybe there is no crlf in the footer) |
49 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
addconfig |
50 |
} |
} |
51 |
|
|
52 |
help_session_addmenuitem() |
helper_rebuild_fluxbox_autostart() |
53 |
{ |
{ |
54 |
mecho "set session.addmenuitem [name] [exec] [workdir] [icon]" |
local CONFIG |
55 |
mecho " adds a fluxbox menu entry" |
|
56 |
mecho " name - menu entry name" |
CONFIG="${MCORE_UNPRIV_HOME}/.fluxbox/apps" |
57 |
mecho " exec - executable to start" |
clearconfig |
58 |
mecho " workdir - working directory for the executable - optional" |
for file in ${MCORE_CONFIG_PATH}/fluxbox/autostart/* |
59 |
mecho " icon - pixmap icon of the entry - optional" |
do |
60 |
|
addconfig "$(< ${file})" |
61 |
|
done |
62 |
|
|
63 |
|
# add a newline (maybe there is no crlf in the footer) |
64 |
|
addconfig |
65 |
} |
} |
66 |
|
|
67 |
# set_session_addmenuitem $name $exec $workdir $icon |
help_fluxbox_menuitem() |
|
set_session_addmenuitem() |
|
68 |
{ |
{ |
69 |
local name="$1" |
mecho "get fluxbox.menuitem" |
70 |
local exec="$2" |
mecho " Shows all custom added menuitems of fluxbox." |
71 |
local workdir="$3" |
mecho |
72 |
local icon="$4" |
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 |
|
} |
85 |
|
|
86 |
echo "[exec] (${name}) {${exec}}" > ${SETTINGSPATH}/fluxbox/menu/${name} |
# set_fluxbox_menuitem $name $exec $workdir $icon |
87 |
|
set_fluxbox_menuitem() |
88 |
|
{ |
89 |
|
local action="$1" |
90 |
|
local name="$2" |
91 |
|
local exec="$3" |
92 |
|
local workdir="$4" |
93 |
|
local icon="$5" |
94 |
|
local CONFIG |
95 |
|
|
96 |
|
[[ -z ${action} ]] && help_fluxbox_menuitem && return 1 |
97 |
|
|
98 |
|
case "${action}" in |
99 |
|
add) |
100 |
|
[[ -z ${name} ]] && help_fluxbox_menuitem && return 1 |
101 |
|
[[ -z ${exec} ]] && help_fluxbox_menuitem && return 1 |
102 |
|
CONFIG="${MCORE_CONFIG_PATH}/fluxbox/menu/${name}" |
103 |
|
clearconfig |
104 |
|
addconfig "[exec] (${name}) {${exec}}" |
105 |
|
;; |
106 |
|
del) |
107 |
|
if [[ -f ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]] |
108 |
|
then |
109 |
|
rm ${MCORE_CONFIG_PATH}/fluxbox/menu/"${name}" |
110 |
|
elif [[ -z ${name} ]] |
111 |
|
then |
112 |
|
# delete all items |
113 |
|
rm ${MCORE_CONFIG_PATH}/fluxbox/menu/* |
114 |
|
fi |
115 |
|
;; |
116 |
|
*) |
117 |
|
help_fluxbox_menuitem && return 1 |
118 |
|
;; |
119 |
|
esac |
120 |
|
|
121 |
# rebuild the menu now |
# rebuild the menu now |
122 |
helper_session_rebuild_fluxbox_menu |
helper_rebuild_fluxbox_menu |
123 |
} |
} |
124 |
|
|
125 |
help_session_delmenuitem() |
# get_fluxbox_menuitem |
126 |
|
get_fluxbox_menuitem() |
127 |
{ |
{ |
128 |
mecho "set session.delmenuitem [name]" |
local i |
129 |
mecho " deletes a fluxbox menu entry" |
local item |
130 |
mecho " name - menu entry name" |
|
131 |
|
for i in $(find ${MCORE_CONFIG_PATH}/fluxbox/menu -type f | sort) |
132 |
|
do |
133 |
|
item="${item} $(basename ${i})" |
134 |
|
done |
135 |
|
|
136 |
|
rvecho "${item}" |
137 |
} |
} |
138 |
|
|
139 |
# set_session_delmenuitem [$name] |
help_fluxbox_theme() |
|
set_session_delmenuitem() |
|
140 |
{ |
{ |
141 |
local name="$1" |
mecho "get fluxbox.theme [method]" |
142 |
|
mecho " Displays current installed or system-wide available themes." |
143 |
|
mecho " Methods:" |
144 |
|
mecho " system - shows systemwide available themes" |
145 |
|
mecho " current - shows current selected theme" |
146 |
|
mecho |
147 |
|
mecho "set fluxbox.theme [theme]" |
148 |
|
mecho " Sets a default theme for fluxbox." |
149 |
|
} |
150 |
|
|
151 |
if [[ -f ${SETTINGSPATH}/fluxbox/menu/${name} ]] |
set_fluxbox_theme() |
152 |
then |
{ |
153 |
rm ${SETTINGSPATH}/fluxbox/menu/${name} |
local theme="$1" |
154 |
elif [[ -z ${name} ]] |
local stylesdir="/usr/share/fluxbox/styles" |
155 |
|
|
156 |
|
[[ -z ${theme} ]] && help_fluxbox_theme && return 1 |
157 |
|
[[ ! -x $(which fluxbox-remote) ]] && eecho "fluxbox-remote missing! Aborted" && return 1 |
158 |
|
|
159 |
|
if [[ -e ${stylesdir}/${theme} ]] |
160 |
then |
then |
161 |
# delete all items |
x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'" |
162 |
rm ${SETTINGSPATH}/fluxbox/menu/* |
else |
163 |
|
eechoe "Theme '${theme}' does not exist!" |
164 |
fi |
fi |
165 |
|
} |
166 |
|
|
167 |
# rebuild the menu now |
get_fluxbox_theme() |
168 |
helper_session_rebuild_fluxbox_menu |
{ |
169 |
|
local method="$1" |
170 |
|
local stylesdir="/usr/share/fluxbox/styles" |
171 |
|
local value |
172 |
|
local i |
173 |
|
|
174 |
|
[[ -z ${method} ]] && help_fluxbox_theme && return 1 |
175 |
|
|
176 |
|
case "${method}" in |
177 |
|
system) |
178 |
|
for i in $(find ${stylesdir} -mindepth 1 -maxdepth 1 | sort) |
179 |
|
do |
180 |
|
value="${value} $(basename ${i})" |
181 |
|
done |
182 |
|
rvecho "${value}" |
183 |
|
;; |
184 |
|
|
185 |
|
current) |
186 |
|
value=$(grep -i '^session.stylefile' ${MCORE_UNPRIV_HOME}/.fluxbox/init | sed 's:.*/\(.*\):\1:') |
187 |
|
rvecho "${value}" |
188 |
|
;; |
189 |
|
*) help_fluxbox_theme && return 1 ;; |
190 |
|
esac |
191 |
} |
} |