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 '[nop] (__________)' |
43 |
|
addconfig '[exec] (Neustarten) {sudo /sbin/reboot}' |
44 |
|
addconfig '[exec] (Herunterfahren) {sudo /sbin/halt}' |
45 |
|
addconfig '[end]' |
46 |
|
|
47 |
# add a newline (maybe there is no crlf in the footer) |
# add a newline (maybe there is no crlf in the footer) |
48 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
addconfig |
49 |
} |
} |
50 |
|
|
51 |
help_session_addmenuitem() |
help_fluxbox_menuitem() |
52 |
{ |
{ |
53 |
mecho "set session.addmenuitem [name] [exec] [workdir] [icon]" |
mecho "get fluxbox.menuitem" |
54 |
mecho " adds a fluxbox menu entry" |
mecho " Shows all custom added menuitems of fluxbox." |
55 |
mecho " name - menu entry name" |
mecho |
56 |
mecho " exec - executable to start" |
mecho "set fluxbox.menuitem [action] [name] [exec] [workdir] [icon]" |
57 |
mecho " workdir - working directory for the executable - optional" |
mecho " Adds or deletes a fluxbox menu entry." |
58 |
mecho " icon - pixmap icon of the entry - optional" |
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_session_addmenuitem $name $exec $workdir $icon |
# set_fluxbox_menuitem $name $exec $workdir $icon |
71 |
set_session_addmenuitem() |
set_fluxbox_menuitem() |
72 |
{ |
{ |
73 |
local name="$1" |
local action="$1" |
74 |
local exec="$2" |
local name="$2" |
75 |
local workdir="$3" |
local exec="$3" |
76 |
local icon="$4" |
local workdir="$4" |
77 |
|
local icon="$5" |
78 |
echo "[exec] (${name}) {${exec}}" > ${SETTINGSPATH}/fluxbox/menu/${name} |
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 |
# rebuild the menu now |
106 |
helper_session_rebuild_fluxbox_menu |
helper_rebuild_fluxbox_menu |
107 |
} |
} |
108 |
|
|
109 |
help_session_delmenuitem() |
# get_fluxbox_menuitem |
110 |
|
get_fluxbox_menuitem() |
111 |
{ |
{ |
112 |
mecho "set session.delmenuitem [name]" |
local i |
113 |
mecho " deletes a fluxbox menu entry" |
local item |
114 |
mecho " name - menu entry name" |
|
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 |
# set_session_delmenuitem [$name] |
help_fluxbox_theme() |
|
set_session_delmenuitem() |
|
124 |
{ |
{ |
125 |
local name="$1" |
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 |
if [[ -f ${SETTINGSPATH}/fluxbox/menu/${name} ]] |
set_fluxbox_theme() |
136 |
then |
{ |
137 |
rm ${SETTINGSPATH}/fluxbox/menu/${name} |
local theme="$1" |
138 |
elif [[ -z ${name} ]] |
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 |
then |
145 |
# delete all items |
x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'" |
146 |
rm ${SETTINGSPATH}/fluxbox/menu/* |
else |
147 |
|
eechoe "Theme '${theme}' does not exist!" |
148 |
fi |
fi |
149 |
|
} |
150 |
|
|
151 |
# rebuild the menu now |
get_fluxbox_theme() |
152 |
helper_session_rebuild_fluxbox_menu |
{ |
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 |
} |
} |