2 |
|
|
3 |
provide idesk basic-icons |
provide idesk basic-icons |
4 |
|
|
5 |
helper_generate_icon() |
help_idesk_icon() |
6 |
{ |
{ |
7 |
local name |
mecho "get idesk.icon" |
8 |
local icon |
mecho " Shows all configured icons." |
9 |
local command |
mecho |
10 |
local dest |
mecho "set idesk.icons [action] [name] [command] [icon] [filename] [x,y] [width,height] [default-icon]" |
11 |
local yres |
mecho " Adds or deletes an desktop icon." |
12 |
|
mecho " [actions]:" |
13 |
|
mecho " add - adds an icon" |
14 |
|
mecho " del - deletes an icon" |
15 |
|
mecho " if no [name] given, all desktop icons will be deleted" |
16 |
|
mecho |
17 |
|
mecho " name - Name of the icon" |
18 |
|
mecho " command - command which will be run" |
19 |
|
mecho " icon - icon pixmap [optional]" |
20 |
|
mecho " filename - filename of the icon [optional]" |
21 |
|
mecho " x,y - x,y position of the icon on the desktop [optional]" |
22 |
|
mecho " width,height - width and height of the icon [optional]" |
23 |
|
mecho " default-icon - default icon which will be selected if the icon pixmap was not found [optional]" |
24 |
|
} |
25 |
|
|
26 |
|
get_idesk_icon() |
27 |
|
{ |
28 |
|
${MLIBDIR}/idesk-generate-icon-info --print |
29 |
|
} |
30 |
|
|
31 |
|
set_idesk_icon() |
32 |
|
{ |
33 |
|
local action="${CLASS_ARGV[0]}" |
34 |
|
local name="${CLASS_ARGV[1]}" |
35 |
|
local command="${CLASS_ARGV[2]}" |
36 |
|
local icon="${CLASS_ARGV[3]}" |
37 |
|
local filename="${CLASS_ARGV[4]}" |
38 |
|
local xyres="${CLASS_ARGV[5]}" |
39 |
|
local widthheight="${CLASS_ARGV[6]}" |
40 |
|
local deficon="${CLASS_ARGV[7]}" |
41 |
|
local i |
42 |
local xres |
local xres |
43 |
|
local yres |
44 |
local iwidth |
local iwidth |
45 |
local iheight |
local iheight |
|
local deficon |
|
|
local CONFIG |
|
|
local utility |
|
|
|
|
|
# very basic getops |
|
|
for i in $* |
|
|
do |
|
|
case $1 in |
|
|
--name|-n) shift; name="$1" ;; |
|
|
--command|-c) shift; command="$1" ;; |
|
|
--icon|-i) shift; icon="$1" ;; |
|
|
--dest|-d) shift; dest="$1" ;; |
|
|
--xres|-x) shift; xres="$1" ;; |
|
|
--yres|-y) shift; yres="$1" ;; |
|
|
--icon-width|-w) shift; iwidth="$1" ;; |
|
|
--icon-height|-h) shift; iheight="$1" ;; |
|
|
--default-icon) shift; deficon="$1" ;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
# some sanity checks: |
|
|
|
|
|
# abort if name or command not given |
|
|
[[ -z ${name} ]] && return 1 |
|
|
[[ -z ${command} ]] && return 1 |
|
|
|
|
|
[[ -z ${dest} ]] && dest="${MCORE_UNPRIV_HOME}/.idesktop/${name}.lnk" |
|
|
|
|
|
# use some defaults for icon, dest, {x,y}res |
|
|
[[ -z ${xres} ]] && xres=50 |
|
|
[[ -z ${yres} ]] && xres=50 |
|
|
if [[ -z ${icon} ]] || [ ! -f ${icon} ] |
|
|
then |
|
|
# if no default icon is given use default.png |
|
|
[[ -z ${deficon} ]] && deficon="default.png" |
|
|
icon="@@PIXMAPSDIR@@/${deficon}" |
|
|
fi |
|
|
|
|
|
CONFIG="${dest}" |
|
|
clearconfig |
|
46 |
|
|
47 |
addconfig 'table Icon' |
[[ -z ${action} ]] && help_idesk_icon && return 1 |
|
addconfig " Caption: ${name}" |
|
|
addconfig " Command: ${command}" |
|
|
addconfig " Icon: ${icon}" |
|
|
addconfig " X: ${xres}" |
|
|
addconfig " Y: ${yres}" |
|
48 |
|
|
49 |
# add these only if not zero |
if [[ -n ${xyres} ]] |
|
if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]] |
|
50 |
then |
then |
51 |
addconfig " Width: ${iwidth}" |
xres="${xyres%,*}" |
52 |
addconfig " Height: ${iheight}" |
yres="${xyres#*,}" |
53 |
fi |
fi |
54 |
|
|
55 |
addconfig 'end' |
if [[ -n ${widthheight} ]] |
56 |
} |
then |
57 |
|
iwidth="${widthheight%,*}" |
58 |
helper_generate_all_desktop_icons() |
iheight="${widthheight#*,}" |
59 |
{ |
fi |
|
local session_list="$1" |
|
|
local other_menuitem_list="$2" |
|
|
local plugin_list="$3" |
|
|
local res |
|
|
local xres |
|
|
local yres |
|
|
local x |
|
|
local y |
|
|
local i |
|
|
local name |
|
|
local progsh_path |
|
|
local utility |
|
|
local dest |
|
|
local rc |
|
|
|
|
|
dest="${MCORE_UNPRIV_HOME}/.idesktop" |
|
|
rc="${MCORE_UNPRIV_HOME}/.ideskrc" |
|
|
|
|
|
# progs path |
|
|
progsh_path="${MCORE_UNPRIV_HOME}/.progs" |
|
|
|
|
|
# get the resolution |
|
|
res=$(mysqldo "select resolution from cfg_graphic where serial='${MCORE_SERIAL}'") |
|
|
|
|
|
# split res to x & y |
|
|
xres="${res%x*}" |
|
|
yres="${res#*x}" |
|
|
|
|
|
# top left edge of the icon is given in config file |
|
|
# remove a little bit to simulate the bottom-right edge |
|
|
xres="$(( ${xres} - 120 ))" |
|
|
yres="$(( ${yres} - 80 ))" |
|
|
|
|
|
# clean desktop icon location |
|
|
[ -d ${dest} ] && rm -rf ${dest} |
|
|
[ -f ${rc} ] && rm -f ${rc} |
|
|
install -d ${dest} |
|
|
|
|
|
# default settings |
|
|
declare -i x=50 |
|
|
declare -i y=50 |
|
|
|
|
|
# ica icons |
|
|
for i in ${session_list} |
|
|
do |
|
|
# abort if empty |
|
|
[[ -z ${i} ]] && continue |
|
|
|
|
|
# get database information |
|
|
evaluate_table cfg_sessions "where serial='${MCORE_SERIAL}' and id='${i}'" |
|
|
|
|
|
# new line if x > xres |
|
|
if [ ${x} -ge ${xres} ] |
|
|
then |
|
|
x=50 |
|
|
y=$((${y} + 80)) |
|
|
fi |
|
|
|
|
|
# new row if y > yres |
|
|
if [ ${y} -ge ${yres} ] |
|
|
then |
|
|
x=$((${x} + 120)) |
|
|
y=50 |
|
|
|
|
|
# re-check x |
|
|
[ ${x} -ge ${xres} ] && x=50 |
|
|
fi |
|
|
|
|
|
generate_icon \ |
|
|
--name "${cfg_sessions_session}" \ |
|
|
--command "nice -n 19 wfica ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})" \ |
|
|
--icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_sessions_session}).png" \ |
|
|
--dest "${dest}/$(fix_whitespaces ${cfg_sessions_session}).lnk" \ |
|
|
--xres "${x}" \ |
|
|
--yres "${y}" |
|
|
|
|
|
y=$((${y} + 80)) |
|
|
done |
|
|
|
|
|
for i in ${other_menuitem_list} |
|
|
do |
|
|
# abort if empty |
|
|
[[ -z ${i} ]] && continue |
|
|
|
|
|
# get database information |
|
|
evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'" |
|
|
|
|
|
# new line if x > xres |
|
|
if [ ${x} -ge ${xres} ] |
|
|
then |
|
|
x=50 |
|
|
y=$((${y} + 80)) |
|
|
fi |
|
|
|
|
|
# new row if y > yres |
|
|
if [ ${y} -ge ${yres} ] |
|
|
then |
|
|
x=$((${x} + 120)) |
|
|
y=50 |
|
|
|
|
|
# re-check x |
|
|
[ ${x} -ge ${xres} ] && x=50 |
|
|
fi |
|
|
|
|
|
generate_icon \ |
|
|
--name "${cfg_other_menuitems_name}" \ |
|
|
--command "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \ |
|
|
--icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_other_menuitems_name}).png" \ |
|
|
--dest "${dest}/$(fix_whitespaces ${cfg_other_menuitems_name}).lnk" \ |
|
|
--xres "${x}" \ |
|
|
--yres "${y}" \ |
|
|
--default-icon "default_item.png" |
|
|
|
|
|
y=$((${y} + 80)) |
|
|
done |
|
|
|
|
|
for i in ${plugin_list} |
|
|
do |
|
|
# abort if empty |
|
|
[[ -z ${i} ]] && continue |
|
|
|
|
|
evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'" |
|
|
if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] |
|
|
then |
|
|
eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh menuitem) |
|
|
|
|
|
# abort if name or exec is empty |
|
|
[[ -z ${PLUGIN_MENUITEM_NAME} ]] && continue |
|
|
[[ -z ${PLUGIN_MENUITEM_EXEC} ]] && continue |
|
60 |
|
|
61 |
# new line if x > xres |
case "${action}" in |
62 |
if [ ${x} -ge ${xres} ] |
add) |
63 |
then |
# requires name |
64 |
x=50 |
[[ -z ${name} ]] && help_idesk_icon && return 1 |
65 |
y=$((${y} + 80)) |
# and session |
66 |
fi |
[[ -z ${command} ]] && help_idesk_icon && return 1 |
67 |
|
|
68 |
|
# create a desktop icon |
69 |
|
${MCORE_LIBDIR}/idesk-generate-icon-info \ |
70 |
|
--add \ |
71 |
|
--name "${name}" \ |
72 |
|
--command "${command}" \ |
73 |
|
--icon "${icon}" \ |
74 |
|
--filename "${filename}" \ |
75 |
|
--xres "${xres}" \ |
76 |
|
--yres "${yres}" \ |
77 |
|
--icon-width "${iwidth}" \ |
78 |
|
--icon-height "${iheight}" \ |
79 |
|
--default-icon "${deficon}" |
80 |
|
;; |
81 |
|
|
82 |
# new row if y > yres |
del) |
83 |
if [ ${y} -ge ${yres} ] |
if [[ -n ${name} ]] |
84 |
then |
then |
85 |
x=$((${x} + 120)) |
${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${name}" |
86 |
y=50 |
else |
87 |
|
for i in $(NOCOLORS=true ${MCORE_LIBDIR}/idesk-generate-icon-info --print) |
88 |
# re-check x |
do |
89 |
[ ${x} -ge ${xres} ] && x=50 |
# basename |
90 |
|
name="${i%.*}" |
91 |
|
${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${name}" |
92 |
|
done |
93 |
fi |
fi |
94 |
|
;; |
95 |
|
|
96 |
generate_icon \ |
*) help_idesk_icon && return 1 ;; |
97 |
--name "${PLUGIN_MENUITEM_NAME}" \ |
esac |
|
--command "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \ |
|
|
--icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).png" \ |
|
|
--dest "${dest}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).lnk" \ |
|
|
--xres "${x}" \ |
|
|
--yres "${y}" \ |
|
|
--default-icon "default_item.png" |
|
|
|
|
|
y=$((${y} + 80)) |
|
|
fi |
|
|
|
|
|
# unset all variables |
|
|
unset PLUGIN_MENUITEM_NAME |
|
|
unset PLUGIN_MENUITEM_EXEC |
|
|
unset PLUGIN_MENUITEM_PARAM |
|
|
unset PLUGIN_MENUITEM_WORKDIR |
|
|
unset PLUGIN_MENUITEM_ICON |
|
|
done |
|
|
|
|
|
# add shutdown, reboot icons |
|
|
for i in shutdown reboot |
|
|
do |
|
|
# new line if x > xres |
|
|
if [ ${x} -ge ${xres} ] |
|
|
then |
|
|
x=50 |
|
|
y=$((${y} + 80)) |
|
|
fi |
|
|
|
|
|
# new row if y > yres |
|
|
if [ ${y} -ge ${yres} ] |
|
|
then |
|
|
x=$((${x} + 120)) |
|
|
y=50 |
|
|
|
|
|
# re-check x |
|
|
[ ${x} -ge ${xres} ] && x=50 |
|
|
fi |
|
|
|
|
|
case ${i} in |
|
|
shutdown) name="Herunterfahren" ;; |
|
|
reboot) name="Neustarten" ;; |
|
|
esac |
|
|
|
|
|
generate_icon \ |
|
|
--name "${name}" \ |
|
|
--command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \ |
|
|
--icon "${ALX_SESSIONS_ICONS}/${i}.png" \ |
|
|
--dest "${dest}/${i}.lnk" \ |
|
|
--xres "${x}" \ |
|
|
--yres "${y}" \ |
|
|
--icon-width "40" \ |
|
|
--icon-height "40" |
|
|
|
|
|
y=$((${y} + 80)) |
|
|
done |
|
|
|
|
|
# last but not least gen a icon with some sys informations |
|
|
local sysinfo |
|
|
local hostname |
|
|
local osversion |
|
|
|
|
|
osversion="$(< /etc/mageversion)" |
|
|
hostname=$(mysqldo "select hostname from cfg_network where serial='${ALX_SERIAL}'") |
|
|
sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" |
|
|
|
|
|
# now get the right position: |
|
|
# restore orig values of xres |
|
|
xres="$(( ${xres} + 120 ))" |
|
|
# default y pos (full yres -22 = cur yres + 58 !) |
|
|
yres="$(( ${yres} + 58 ))" |
|
|
# middle of the screen |
|
|
# (no txt - length required, xtdesk manage that itself) |
|
|
xres="$(( ${xres} / 2))" |
|
|
|
|
|
generate_icon \ |
|
|
--name "${sysinfo}" \ |
|
|
--command "exit 0" \ |
|
|
--icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ |
|
|
--dest "${dest}/sysinfo.lnk" \ |
|
|
--xres "${xres}" \ |
|
|
--yres "${yres}" \ |
|
|
--icon-width "1" \ |
|
|
--icon-height "1" |
|
98 |
} |
} |
|
|
|