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_session_rebuild_fluxbox_menu() |
|
9 |
{ |
{ |
10 |
:> ${SETTINGSPATH}/fluxbox/alxmenu |
mecho "get fluxbox.menuitem" |
11 |
|
mecho " Shows all custom added menuitems of fluxbox." |
12 |
for file in ${SETTINGSPATH}/fluxbox/menu/* |
mecho |
13 |
do |
mecho "set fluxbox.menuitem [action] [name] [exec] [workdir] [icon]" |
14 |
echo "[include] (${file})" >> ${SETTINGSPATH}/fluxbox/alxmenu |
mecho " Adds or deletes a fluxbox menu entry." |
15 |
done |
mecho " Actions:" |
16 |
|
mecho " add - adds a menuitem" |
17 |
# rebuild the user menu too atm |
mecho " del - deletes a menuitem" |
18 |
cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu |
mecho |
19 |
|
mecho " name - menu entry name" |
20 |
# now fix it with proper messages :P |
mecho " exec - executable to start" |
21 |
local ver="$(< /etc/mageversion)" |
mecho " workdir - working directory for the executable - optional" |
22 |
sed -i "s:@CHANGEME@:tinyALX-${ver} #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu |
mecho " icon - pixmap icon of the entry - optional" |
23 |
|
mecho |
24 |
# add a newline (maybe there is no crlf in the header) |
mecho " If no [name] given, all entries will be deleted." |
|
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
|
|
|
|
|
# our specific include |
|
|
echo "[include] (${SETTINGSPATH}/fluxbox/alxmenu)" >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
|
|
|
|
|
# fluxbox menu footer |
|
|
cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
|
|
|
|
|
# add a newline (maybe there is no crlf in the footer) |
|
|
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
|
25 |
} |
} |
26 |
|
|
27 |
help_session_addmenuitem() |
# set_fluxbox_menuitem $name $exec $workdir $icon |
28 |
|
set_fluxbox_menuitem() |
29 |
{ |
{ |
30 |
mecho "set session.addmenuitem [name] [exec] [workdir] [icon]" |
local action="${CLASS_ARGV[0]}" |
31 |
mecho " adds a fluxbox menu entry" |
local name="${CLASS_ARGV[1]}" |
32 |
mecho " name - menu entry name" |
local exec="${CLASS_ARGV[2]}" |
33 |
mecho " exec - executable to start" |
local workdir="${CLASS_ARGV[3]}" |
34 |
mecho " workdir - working directory for the executable - optional" |
local icon="${CLASS_ARGV[4]}" |
35 |
mecho " icon - pixmap icon of the entry - optional" |
local CONFIG |
36 |
|
|
37 |
|
[[ -z ${action} ]] && help_fluxbox_menuitem && return 1 |
38 |
|
|
39 |
|
case "${action}" in |
40 |
|
add) |
41 |
|
[[ -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 |
63 |
|
fluxbox-rebuild-menu |
64 |
} |
} |
65 |
|
|
66 |
# set_session_addmenuitem $name $exec $workdir $icon |
# get_fluxbox_menuitem |
67 |
set_session_addmenuitem() |
get_fluxbox_menuitem() |
68 |
{ |
{ |
69 |
local name="$1" |
list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu |
|
local exec="$2" |
|
|
local workdir="$3" |
|
|
local icon="$4" |
|
|
|
|
|
echo "[exec] (${name}) {${exec}}" > ${SETTINGSPATH}/fluxbox/menu/${name} |
|
|
|
|
|
# rebuild the menu now |
|
|
helper_session_rebuild_fluxbox_menu |
|
70 |
} |
} |
71 |
|
|
72 |
help_session_delmenuitem() |
help_fluxbox_theme() |
73 |
{ |
{ |
74 |
mecho "set session.delmenuitem [name]" |
mecho "get fluxbox.theme [method]" |
75 |
mecho " deletes a fluxbox menu entry" |
mecho " Displays current installed or system-wide available themes." |
76 |
mecho " name - menu entry name" |
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 |
# set_session_delmenuitem [$name] |
set_fluxbox_theme() |
|
set_session_delmenuitem() |
|
85 |
{ |
{ |
86 |
local name="$1" |
local theme="${CLASS_ARGV[0]}" |
87 |
|
local stylesdir="@@DATADIR@@/fluxbox/styles" |
88 |
|
|
89 |
if [[ -f ${SETTINGSPATH}/fluxbox/menu/${name} ]] |
[[ -z ${theme} ]] && help_fluxbox_theme && return 1 |
90 |
then |
[[ ! -x $(type -P fluxbox-remote) ]] && eecho "fluxbox-remote missing! Aborted" && return 1 |
91 |
rm ${SETTINGSPATH}/fluxbox/menu/${name} |
|
92 |
elif [[ -z ${name} ]] |
if [[ -e ${stylesdir}/${theme} ]] |
93 |
then |
then |
94 |
# delete all items |
x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'" |
95 |
rm ${SETTINGSPATH}/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_session_rebuild_fluxbox_menu |
{ |
102 |
|
local method="${CLASS_ARGV[0]}" |
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 |
} |
} |