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 |
help_fluxbox_menuitem() |
|
helper_rebuild_fluxbox_menu() |
|
9 |
{ |
{ |
10 |
local MMINCLUDE |
mecho "get fluxbox.menuitem" |
11 |
local CONFIG |
mecho " Shows all custom added menuitems of fluxbox." |
12 |
|
mecho |
13 |
MMINCLUDE="${MCORE_CONFIG_PATH}/fluxbox/mcore-menu-include" |
mecho "set fluxbox.menuitem [action] [name] [exec] [workdir] [icon]" |
14 |
CONFIG="${MMINCLUDE}" |
mecho " Adds or deletes a fluxbox menu entry." |
15 |
clearconfig |
mecho " Actions:" |
16 |
|
mecho " add - adds a menuitem" |
17 |
for file in ${MCORE_CONFIG_PATH}/fluxbox/menu/* |
mecho " del - deletes a menuitem" |
18 |
do |
mecho |
19 |
addconfig "[include] (${file})" |
mecho " name - menu entry name" |
20 |
done |
mecho " exec - executable to start" |
21 |
|
mecho " workdir - working directory for the executable - optional" |
22 |
# rebuild the user menu too atm |
mecho " icon - pixmap icon of the entry - optional" |
23 |
CONFIG="${MCORE_UNPRIV_HOME}/.fluxbox/menu" |
mecho |
24 |
if [[ ! -d ${MCORE_UNPRIV_HOME}/.fluxbox ]] |
mecho " If no [name] given, all entries will be deleted." |
|
then |
|
|
install -o ${MCORE_UNPRIV_USER} -o ${MCORE_UNPRIV_GROUP} -d ${MCORE_UNPRIV_HOME}/.fluxbox |
|
|
fi |
|
|
|
|
|
# fluxbox menu header |
|
|
clearconfig |
|
|
local ver="$(< /etc/mageversion)" |
|
|
addconfig "[begin] (mCore-${ver} #${MCORE_SERIAL})" |
|
|
|
|
|
# add a newline (maybe there is no crlf in the header) |
|
|
addconfig |
|
|
|
|
|
# our specific menu include |
|
|
addconfig "[include] (${MMINCLUDE})" |
|
|
|
|
|
# fluxbox menu footer |
|
|
addconfig '[nop] (__________)' |
|
|
addconfig '[exec] (Neustarten) {sudo reboot}' |
|
|
addconfig '[exec] (Herunterfahren) {sudo halt}' |
|
|
addconfig '[end]' |
|
|
|
|
|
# add a newline (maybe there is no crlf in the footer) |
|
|
addconfig |
|
25 |
} |
} |
26 |
|
|
27 |
help_fluxbox_addmenuitem() |
# set_fluxbox_menuitem $name $exec $workdir $icon |
28 |
|
set_fluxbox_menuitem() |
29 |
{ |
{ |
30 |
mecho "set fluxbox.addmenuitem [name] [exec] [workdir] [icon]" |
local action="$1" |
31 |
mecho " adds a fluxbox menu entry" |
local name="$2" |
32 |
mecho " name - menu entry name" |
local exec="$3" |
33 |
mecho " exec - executable to start" |
local workdir="$4" |
34 |
mecho " workdir - working directory for the executable - optional" |
local icon="$5" |
|
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" |
|
35 |
local CONFIG |
local CONFIG |
36 |
|
|
37 |
[[ -z ${name} ]] && help_session_addmenuitem && return 1 |
[[ -z ${action} ]] && help_fluxbox_menuitem && return 1 |
|
[[ -z ${exec} ]] && help_session_addmenuitem && return 1 |
|
38 |
|
|
39 |
CONFIG="${MCORE_CONFIG_PATH}/fluxbox/menu/${name}" |
case "${action}" in |
40 |
clearconfig |
add) |
41 |
addconfig "[exec] (${name}) {${exec}}" |
[[ -z ${name} ]] && help_fluxbox_menuitem && return 1 |
42 |
|
[[ -z ${exec} ]] && help_fluxbox_menuitem && return 1 |
43 |
|
CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/${name}" |
44 |
|
clearconfig |
45 |
|
addconfig "[exec] (${name}) {${exec}}" |
46 |
|
;; |
47 |
|
del) |
48 |
|
if [[ -f ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]] |
49 |
|
then |
50 |
|
rm ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/"${name}" |
51 |
|
elif [[ -z ${name} ]] |
52 |
|
then |
53 |
|
# delete all items |
54 |
|
find ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu -type f | xargs --no-run-if-empty rm |
55 |
|
fi |
56 |
|
;; |
57 |
|
*) |
58 |
|
help_fluxbox_menuitem && return 1 |
59 |
|
;; |
60 |
|
esac |
61 |
|
|
62 |
# rebuild the menu now |
# rebuild the menu now |
63 |
helper_rebuild_fluxbox_menu |
fluxbox-rebuild-menu |
64 |
} |
} |
65 |
|
|
66 |
help_fluxbox_delmenuitem() |
# get_fluxbox_menuitem |
67 |
|
get_fluxbox_menuitem() |
68 |
{ |
{ |
69 |
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." |
|
70 |
} |
} |
71 |
|
|
72 |
# set_fluxbox_delmenuitem [$name] |
help_fluxbox_theme() |
|
set_fluxbox_delmenuitem() |
|
73 |
{ |
{ |
74 |
local name="$1" |
mecho "get fluxbox.theme [method]" |
75 |
|
mecho " Displays current installed or system-wide available themes." |
76 |
|
mecho " Methods:" |
77 |
|
mecho " system - shows systemwide available themes" |
78 |
|
mecho " current - shows current selected theme" |
79 |
|
mecho |
80 |
|
mecho "set fluxbox.theme [theme]" |
81 |
|
mecho " Sets a default theme for fluxbox." |
82 |
|
} |
83 |
|
|
84 |
if [[ -f ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]] |
set_fluxbox_theme() |
85 |
then |
{ |
86 |
rm ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} |
local theme="$1" |
87 |
elif [[ -z ${name} ]] |
local stylesdir="@@DATADIR@@/fluxbox/styles" |
88 |
|
|
89 |
|
[[ -z ${theme} ]] && help_fluxbox_theme && return 1 |
90 |
|
[[ ! -x $(type -P fluxbox-remote) ]] && eecho "fluxbox-remote missing! Aborted" && return 1 |
91 |
|
|
92 |
|
if [[ -e ${stylesdir}/${theme} ]] |
93 |
then |
then |
94 |
# delete all items |
x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'" |
95 |
rm ${MCORE_CONFIG_PATH}/fluxbox/menu/* |
else |
96 |
|
eecho "Theme '${theme}' does not exist!" |
97 |
fi |
fi |
98 |
|
} |
99 |
|
|
100 |
# rebuild the menu now |
get_fluxbox_theme() |
101 |
helper_rebuild_fluxbox_menu |
{ |
102 |
|
local method="$1" |
103 |
|
local stylesdir="@@DATADIR@@/fluxbox/styles" |
104 |
|
local value |
105 |
|
local i |
106 |
|
|
107 |
|
[[ -z ${method} ]] && help_fluxbox_theme && return 1 |
108 |
|
|
109 |
|
case "${method}" in |
110 |
|
system) |
111 |
|
list_files_in_directory -type d -mindepth 1 -maxdepth 1 ${MROOT}/${stylesdir} |
112 |
|
;; |
113 |
|
|
114 |
|
current) |
115 |
|
value=$(grep -i '^session.stylefile' ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/init | sed 's:.*/\(.*\):\1:') |
116 |
|
rvecho "${value}" |
117 |
|
;; |
118 |
|
*) help_fluxbox_theme && return 1 ;; |
119 |
|
esac |
120 |
} |
} |