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 |
|
|
10 |
{ |
{ |
11 |
local MMINCLUDE |
local MMINCLUDE |
12 |
local CONFIG |
local CONFIG |
13 |
|
local file |
14 |
|
local ver |
15 |
|
|
16 |
MMINCLUDE="${MCORE_CONFIG_PATH}/fluxbox/mcore-menu-include" |
MMINCLUDE="${MCORE_CONFIG_PATH}/fluxbox/mcore-menu-include" |
17 |
CONFIG="${MMINCLUDE}" |
CONFIG="${MROOT}/${MMINCLUDE}" |
18 |
clearconfig |
clearconfig |
19 |
|
for file in $(find ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu -type f) |
|
for file in ${MCORE_CONFIG_PATH}/fluxbox/menu/* |
|
20 |
do |
do |
21 |
|
[[ ! -z ${MROOT} ]] && file=$(echo ${file} | sed "s:${MROOT}::") |
22 |
addconfig "[include] (${file})" |
addconfig "[include] (${file})" |
23 |
done |
done |
24 |
|
|
25 |
# rebuild the user menu too atm |
# rebuild the user menu too atm |
26 |
CONFIG="${MCORE_UNPRIV_HOME}/.fluxbox/menu" |
CONFIG="${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/menu" |
27 |
if [[ ! -d ${MCORE_UNPRIV_HOME}/.fluxbox ]] |
if [[ ! -d ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox ]] |
28 |
then |
then |
29 |
install -o ${MCORE_UNPRIV_USER} -o ${MCORE_UNPRIV_GROUP} -d ${MCORE_UNPRIV_HOME}/.fluxbox |
install -o ${MCORE_UNPRIV_USER} -o ${MCORE_UNPRIV_GROUP} -d ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox |
30 |
fi |
fi |
31 |
|
|
32 |
# fluxbox menu header |
# fluxbox menu header |
33 |
clearconfig |
clearconfig |
34 |
local ver="$(< /etc/mageversion)" |
ver="$(< ${MROOT}/etc/mageversion)" |
35 |
addconfig "[begin] (mCore-${ver} #${MCORE_SERIAL})" |
addconfig "[begin] (${MCORE_DISTRIBUTION}-${ver} #${MCORE_SERIAL})" |
36 |
|
|
37 |
# add a newline (maybe there is no crlf in the header) |
# add a newline (maybe there is no crlf in the header) |
38 |
addconfig |
addconfig |
41 |
addconfig "[include] (${MMINCLUDE})" |
addconfig "[include] (${MMINCLUDE})" |
42 |
|
|
43 |
# fluxbox menu footer |
# fluxbox menu footer |
44 |
addconfig '[nop] (__________)' |
addconfig '[separator]' |
45 |
addconfig '[exec] (Neustarten) {sudo reboot}' |
addconfig '[exit] (Abmelden)' |
46 |
addconfig '[exec] (Herunterfahren) {sudo halt}' |
addconfig '[exec] (Neustarten) {sudo /sbin/reboot}' |
47 |
|
addconfig '[exec] (Herunterfahren) {sudo /sbin/halt}' |
48 |
addconfig '[end]' |
addconfig '[end]' |
49 |
|
|
50 |
# add a newline (maybe there is no crlf in the footer) |
# add a newline (maybe there is no crlf in the footer) |
51 |
addconfig |
addconfig |
52 |
} |
} |
53 |
|
|
54 |
help_fluxbox_addmenuitem() |
helper_rebuild_fluxbox_autostart() |
55 |
{ |
{ |
|
mecho "set fluxbox.addmenuitem [name] [exec] [workdir] [icon]" |
|
|
mecho " adds a fluxbox menu entry" |
|
|
mecho " name - menu entry name" |
|
|
mecho " exec - executable to start" |
|
|
mecho " workdir - working directory for the executable - optional" |
|
|
mecho " icon - pixmap icon of the entry - optional" |
|
|
} |
|
|
|
|
|
# set_fluxbox_addmenuitem $name $exec $workdir $icon |
|
|
set_fluxbox_addmenuitem() |
|
|
{ |
|
|
local name="$1" |
|
|
local exec="$2" |
|
|
local workdir="$3" |
|
|
local icon="$4" |
|
56 |
local CONFIG |
local CONFIG |
57 |
|
|
58 |
[[ -z ${name} ]] && help_session_addmenuitem && return 1 |
CONFIG="${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/apps" |
|
[[ -z ${exec} ]] && help_session_addmenuitem && return 1 |
|
|
|
|
|
CONFIG="${MCORE_CONFIG_PATH}/fluxbox/menu/${name}" |
|
59 |
clearconfig |
clearconfig |
60 |
addconfig "[exec] (${name}) {${exec}}" |
for file in $(find ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/autostart -type f) |
61 |
|
do |
62 |
|
addconfig "$(< ${file})" |
63 |
|
done |
64 |
|
|
65 |
|
# add a newline (maybe there is no crlf in the footer) |
66 |
|
addconfig |
67 |
|
} |
68 |
|
|
69 |
|
help_fluxbox_menuitem() |
70 |
|
{ |
71 |
|
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 |
|
} |
87 |
|
|
88 |
|
# set_fluxbox_menuitem $name $exec $workdir $icon |
89 |
|
set_fluxbox_menuitem() |
90 |
|
{ |
91 |
|
local action="$1" |
92 |
|
local name="$2" |
93 |
|
local exec="$3" |
94 |
|
local workdir="$4" |
95 |
|
local icon="$5" |
96 |
|
local CONFIG |
97 |
|
|
98 |
|
[[ -z ${action} ]] && help_fluxbox_menuitem && return 1 |
99 |
|
|
100 |
|
case "${action}" in |
101 |
|
add) |
102 |
|
[[ -z ${name} ]] && help_fluxbox_menuitem && return 1 |
103 |
|
[[ -z ${exec} ]] && help_fluxbox_menuitem && return 1 |
104 |
|
CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/${name}" |
105 |
|
clearconfig |
106 |
|
addconfig "[exec] (${name}) {${exec}}" |
107 |
|
;; |
108 |
|
del) |
109 |
|
if [[ -f ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]] |
110 |
|
then |
111 |
|
rm ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/"${name}" |
112 |
|
elif [[ -z ${name} ]] |
113 |
|
then |
114 |
|
# delete all items |
115 |
|
rm ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/* |
116 |
|
fi |
117 |
|
;; |
118 |
|
*) |
119 |
|
help_fluxbox_menuitem && return 1 |
120 |
|
;; |
121 |
|
esac |
122 |
|
|
123 |
# rebuild the menu now |
# rebuild the menu now |
124 |
helper_rebuild_fluxbox_menu |
helper_rebuild_fluxbox_menu |
125 |
} |
} |
126 |
|
|
127 |
help_fluxbox_delmenuitem() |
# get_fluxbox_menuitem |
128 |
|
get_fluxbox_menuitem() |
129 |
{ |
{ |
130 |
mecho "set session.delmenuitem [name]" |
list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu |
|
mecho " Deletes a fluxbox menu entry." |
|
|
mecho " name - menu entry name" |
|
|
mecho " If no [name] given, all entries are deleted." |
|
131 |
} |
} |
132 |
|
|
133 |
# set_fluxbox_delmenuitem [$name] |
help_fluxbox_theme() |
|
set_fluxbox_delmenuitem() |
|
134 |
{ |
{ |
135 |
local name="$1" |
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 |
|
|
145 |
if [[ -f ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]] |
set_fluxbox_theme() |
146 |
then |
{ |
147 |
rm ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} |
local theme="$1" |
148 |
elif [[ -z ${name} ]] |
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 |
then |
then |
155 |
# delete all items |
x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'" |
156 |
rm ${MCORE_CONFIG_PATH}/fluxbox/menu/* |
else |
157 |
|
eechoe "Theme '${theme}' does not exist!" |
158 |
fi |
fi |
159 |
|
} |
160 |
|
|
161 |
# rebuild the menu now |
get_fluxbox_theme() |
162 |
helper_rebuild_fluxbox_menu |
{ |
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 |
|
list_files_in_directory -type d -mindepth 1 -maxdepth 1 ${MROOT}/${stylesdir} |
173 |
|
;; |
174 |
|
|
175 |
|
current) |
176 |
|
value=$(grep -i '^session.stylefile' ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/init | sed 's:.*/\(.*\):\1:') |
177 |
|
rvecho "${value}" |
178 |
|
;; |
179 |
|
*) help_fluxbox_theme && return 1 ;; |
180 |
|
esac |
181 |
} |
} |