5 |
# what does this plugin provide? |
# what does this plugin provide? |
6 |
provide fluxbox |
provide fluxbox |
7 |
|
|
|
# helper |
|
|
helper_rebuild_fluxbox_menu() |
|
|
{ |
|
|
local MMINCLUDE |
|
|
local CONFIG |
|
|
|
|
|
MMINCLUDE="${MCORE_CONFIG_PATH}/fluxbox/mcore-menu-include" |
|
|
CONFIG="${MMINCLUDE}" |
|
|
clearconfig |
|
|
|
|
|
for file in ${MCORE_CONFIG_PATH}/fluxbox/menu/* |
|
|
do |
|
|
addconfig "[include] (${file})" |
|
|
done |
|
|
|
|
|
# rebuild the user menu too atm |
|
|
CONFIG="${MCORE_UNPRIV_HOME}/.fluxbox/menu" |
|
|
if [[ ! -d ${MCORE_UNPRIV_HOME}/.fluxbox ]] |
|
|
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 /sbin/reboot}' |
|
|
addconfig '[exec] (Herunterfahren) {sudo /sbin/halt}' |
|
|
addconfig '[end]' |
|
|
|
|
|
# add a newline (maybe there is no crlf in the footer) |
|
|
addconfig |
|
|
} |
|
|
|
|
8 |
help_fluxbox_menuitem() |
help_fluxbox_menuitem() |
9 |
{ |
{ |
10 |
mecho "get fluxbox.menuitem" |
mecho "get fluxbox.menuitem" |
27 |
# set_fluxbox_menuitem $name $exec $workdir $icon |
# set_fluxbox_menuitem $name $exec $workdir $icon |
28 |
set_fluxbox_menuitem() |
set_fluxbox_menuitem() |
29 |
{ |
{ |
30 |
local action="$1" |
local action="${CLASS_ARGV[0]}" |
31 |
local name="$2" |
local name="${CLASS_ARGV[1]}" |
32 |
local exec="$3" |
local exec="${CLASS_ARGV[2]}" |
33 |
local workdir="$4" |
local workdir="${CLASS_ARGV[3]}" |
34 |
local icon="$5" |
local icon="${CLASS_ARGV[4]}" |
35 |
local CONFIG |
local CONFIG |
36 |
|
|
37 |
[[ -z ${action} ]] && help_fluxbox_menuitem && return 1 |
[[ -z ${action} ]] && help_fluxbox_menuitem && return 1 |
40 |
add) |
add) |
41 |
[[ -z ${name} ]] && help_fluxbox_menuitem && return 1 |
[[ -z ${name} ]] && help_fluxbox_menuitem && return 1 |
42 |
[[ -z ${exec} ]] && help_fluxbox_menuitem && return 1 |
[[ -z ${exec} ]] && help_fluxbox_menuitem && return 1 |
43 |
CONFIG="${MCORE_CONFIG_PATH}/fluxbox/menu/${name}" |
${MCORE_LIBDIR}/fluxbox-menuitem --add --name "${name}" --exec "${exec}" |
|
clearconfig |
|
|
addconfig "[exec] (${name}) {${exec}}" |
|
44 |
;; |
;; |
45 |
del) |
del) |
46 |
if [[ -f ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]] |
if [[ -n ${name} ]] |
|
then |
|
|
rm ${MCORE_CONFIG_PATH}/fluxbox/menu/"${name}" |
|
|
elif [[ -z ${name} ]] |
|
47 |
then |
then |
48 |
|
${MCORE_LIBDIR}/fluxbox-menuitem --del --name "${name}" |
49 |
|
else |
50 |
# delete all items |
# delete all items |
51 |
rm ${MCORE_CONFIG_PATH}/fluxbox/menu/* |
${MCORE_LIBDIR}/fluxbox-menuitem --del |
52 |
fi |
fi |
53 |
;; |
;; |
54 |
*) |
*) |
57 |
esac |
esac |
58 |
|
|
59 |
# rebuild the menu now |
# rebuild the menu now |
60 |
helper_rebuild_fluxbox_menu |
${MCORE_LIBDIR}/fluxbox-rebuild-menu |
61 |
} |
} |
62 |
|
|
63 |
# get_fluxbox_menuitem |
# get_fluxbox_menuitem |
64 |
get_fluxbox_menuitem() |
get_fluxbox_menuitem() |
65 |
{ |
{ |
66 |
local i |
${MCORE_LIBDIR}/fluxbox-menuitem --print |
67 |
local item |
} |
68 |
|
|
69 |
for i in $(find ${MCORE_CONFIG_PATH}/fluxbox/menu -type f | sort) |
help_fluxbox_autostart() |
70 |
do |
{ |
71 |
item="${item} $(basename ${i})" |
mecho "get fluxbox.autostart" |
72 |
done |
mecho " Shows all custom added autostarts of fluxbox." |
73 |
|
mecho |
74 |
|
mecho "set fluxbox.autostart [action] [name] [exec]" |
75 |
|
mecho " Adds or deletes a fluxbox autostart entry." |
76 |
|
mecho " Actions:" |
77 |
|
mecho " add - adds an autostart entry" |
78 |
|
mecho " del - deletes an autostart entry" |
79 |
|
mecho |
80 |
|
mecho " name - autostart entry name" |
81 |
|
mecho " exec - executable to start" |
82 |
|
mecho |
83 |
|
mecho " If no [name] given, all entries will be deleted." |
84 |
|
} |
85 |
|
|
86 |
mecho "${item}" |
# set_fluxbox_autostart $name $exec |
87 |
|
set_fluxbox_autostart() |
88 |
|
{ |
89 |
|
local action="${CLASS_ARGV[0]}" |
90 |
|
local name="${CLASS_ARGV[1]}" |
91 |
|
local exec="${CLASS_ARGV[2]}" |
92 |
|
local CONFIG |
93 |
|
|
94 |
|
[[ -z ${action} ]] && help_fluxbox_autostart && return 1 |
95 |
|
|
96 |
|
case "${action}" in |
97 |
|
add) |
98 |
|
[[ -z ${name} ]] && help_fluxbox_autostart && return 1 |
99 |
|
[[ -z ${exec} ]] && help_fluxbox_autostart && return 1 |
100 |
|
${MCORE_LIBDIR}/fluxbox-autostart --add --name "${name}" --exec "${exec}" |
101 |
|
;; |
102 |
|
del) |
103 |
|
if [[ -n ${name} ]] |
104 |
|
then |
105 |
|
${MCORE_LIBDIR}/fluxbox-autostart --del --name "${name}" |
106 |
|
else |
107 |
|
# delete all items |
108 |
|
${MCORE_LIBDIR}/fluxbox-autostart --del |
109 |
|
fi |
110 |
|
;; |
111 |
|
*) |
112 |
|
help_fluxbox_autostart && return 1 |
113 |
|
;; |
114 |
|
esac |
115 |
|
|
116 |
|
# rebuild the autostart now |
117 |
|
${MCORE_LIBDIR}/fluxbox-rebuild-autostart |
118 |
|
} |
119 |
|
|
120 |
|
# get_fluxbox_autostart |
121 |
|
get_fluxbox_autostart() |
122 |
|
{ |
123 |
|
${MCORE_LIBDIR}/fluxbox-autostart --print |
124 |
} |
} |
125 |
|
|
126 |
help_fluxbox_theme() |
help_fluxbox_theme() |
137 |
|
|
138 |
set_fluxbox_theme() |
set_fluxbox_theme() |
139 |
{ |
{ |
140 |
local theme="$1" |
local theme="${CLASS_ARGV[0]}" |
141 |
local stylesdir="/usr/share/fluxbox/styles" |
local stylesdir="@@DATADIR@@/fluxbox/styles" |
142 |
|
|
143 |
[[ -z ${theme} ]] && help_fluxbox_theme && return 1 |
[[ -z ${theme} ]] && help_fluxbox_theme && return 1 |
144 |
[[ ! -x $(which fluxbox-remote) ]] && eecho "fluxbox-remote missing! Aborted" && return 1 |
[[ ! -x $(type -P fluxbox-remote) ]] && eecho "fluxbox-remote missing! Aborted" && return 1 |
145 |
|
|
146 |
if [[ -e ${stylesdir}/${theme} ]] |
if [[ -e ${stylesdir}/${theme} ]] |
147 |
then |
then |
148 |
x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'" |
x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'" |
149 |
else |
else |
150 |
eechoe "Theme '${theme}' does not exist!" |
eecho "Theme '${theme}' does not exist!" |
151 |
fi |
fi |
152 |
} |
} |
153 |
|
|
154 |
get_fluxbox_theme() |
get_fluxbox_theme() |
155 |
{ |
{ |
156 |
local method="$1" |
local method="${CLASS_ARGV[0]}" |
157 |
local stylesdir="/usr/share/fluxbox/styles" |
local stylesdir="@@DATADIR@@/fluxbox/styles" |
158 |
local value |
local value |
159 |
local i |
local i |
160 |
|
|
162 |
|
|
163 |
case "${method}" in |
case "${method}" in |
164 |
system) |
system) |
165 |
for i in $(find ${stylesdir} -mindepth 1 -maxdepth 1 | sort) |
list_files_in_directory -type d -mindepth 1 -maxdepth 1 ${MROOT}/${stylesdir} |
|
do |
|
|
value="${value} $(basename ${i})" |
|
|
done |
|
|
mecho "${value}" |
|
166 |
;; |
;; |
167 |
|
|
168 |
current) |
current) |
169 |
value=$(grep -i '^session.stylefile' ${MCORE_UNPRIV_HOME}/.fluxbox/init | sed 's:.*/\(.*\):\1:') |
value=$(grep -i '^session.stylefile' ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/init | sed 's:.*/\(.*\):\1:') |
170 |
mecho "${value}" |
rvecho "${value}" |
171 |
;; |
;; |
172 |
*) help_fluxbox_theme && return 1 ;; |
*) help_fluxbox_theme && return 1 ;; |
173 |
esac |
esac |