Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/daemon/client/include/fluxbox.client.class

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1327 - (hide annotations) (download)
Mon Feb 7 20:03:29 2011 UTC (13 years, 3 months ago) by niro
File size: 4002 byte(s)
-use full pathes to match sudoers file
1 niro 1248 # $Id$
2    
3 niro 1257 # todo wallpaper?
4    
5 niro 1248 # what does this plugin provide?
6     provide fluxbox
7    
8     # helper
9 niro 1253 helper_rebuild_fluxbox_menu()
10 niro 1248 {
11 niro 1253 local MMINCLUDE
12     local CONFIG
13 niro 1248
14 niro 1253 MMINCLUDE="${MCORE_CONFIG_PATH}/fluxbox/mcore-menu-include"
15     CONFIG="${MMINCLUDE}"
16     clearconfig
17    
18     for file in ${MCORE_CONFIG_PATH}/fluxbox/menu/*
19 niro 1248 do
20 niro 1253 addconfig "[include] (${file})"
21 niro 1248 done
22    
23     # rebuild the user menu too atm
24 niro 1253 CONFIG="${MCORE_UNPRIV_HOME}/.fluxbox/menu"
25     if [[ ! -d ${MCORE_UNPRIV_HOME}/.fluxbox ]]
26     then
27     install -o ${MCORE_UNPRIV_USER} -o ${MCORE_UNPRIV_GROUP} -d ${MCORE_UNPRIV_HOME}/.fluxbox
28     fi
29 niro 1248
30 niro 1253 # fluxbox menu header
31     clearconfig
32 niro 1248 local ver="$(< /etc/mageversion)"
33 niro 1253 addconfig "[begin] (mCore-${ver} #${MCORE_SERIAL})"
34 niro 1248
35     # add a newline (maybe there is no crlf in the header)
36 niro 1253 addconfig
37 niro 1248
38 niro 1253 # our specific menu include
39     addconfig "[include] (${MMINCLUDE})"
40 niro 1248
41     # fluxbox menu footer
42 niro 1253 addconfig '[nop] (__________)'
43 niro 1327 addconfig '[exec] (Neustarten) {sudo /sbin/reboot}'
44     addconfig '[exec] (Herunterfahren) {sudo /sbin/halt}'
45 niro 1253 addconfig '[end]'
46 niro 1248
47     # add a newline (maybe there is no crlf in the footer)
48 niro 1253 addconfig
49 niro 1248 }
50    
51 niro 1257 help_fluxbox_menuitem()
52 niro 1248 {
53 niro 1257 mecho "get fluxbox.menuitem"
54     mecho " Shows all custom added menuitems of fluxbox."
55     mecho
56     mecho "set fluxbox.menuitem [action] [name] [exec] [workdir] [icon]"
57     mecho " Adds or deletes a fluxbox menu entry."
58     mecho " Actions:"
59     mecho " add - adds a menuitem"
60     mecho " del - deletes a menuitem"
61     mecho
62     mecho " name - menu entry name"
63     mecho " exec - executable to start"
64     mecho " workdir - working directory for the executable - optional"
65     mecho " icon - pixmap icon of the entry - optional"
66     mecho
67     mecho " If no [name] given, all entries will be deleted."
68 niro 1248 }
69    
70 niro 1257 # set_fluxbox_menuitem $name $exec $workdir $icon
71     set_fluxbox_menuitem()
72 niro 1248 {
73 niro 1257 local action="$1"
74     local name="$2"
75     local exec="$3"
76     local workdir="$4"
77     local icon="$5"
78 niro 1253 local CONFIG
79 niro 1248
80 niro 1257 [[ -z ${action} ]] && help_fluxbox_menuitem && return 1
81 niro 1248
82 niro 1257 case "${action}" in
83     add)
84     [[ -z ${name} ]] && help_fluxbox_menuitem && return 1
85     [[ -z ${exec} ]] && help_fluxbox_menuitem && return 1
86     CONFIG="${MCORE_CONFIG_PATH}/fluxbox/menu/${name}"
87     clearconfig
88     addconfig "[exec] (${name}) {${exec}}"
89     ;;
90     del)
91     if [[ -f ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]]
92     then
93     rm ${MCORE_CONFIG_PATH}/fluxbox/menu/"${name}"
94     elif [[ -z ${name} ]]
95     then
96     # delete all items
97     rm ${MCORE_CONFIG_PATH}/fluxbox/menu/*
98     fi
99     ;;
100     *)
101     help_fluxbox_menuitem && return 1
102     ;;
103     esac
104 niro 1253
105 niro 1248 # rebuild the menu now
106 niro 1253 helper_rebuild_fluxbox_menu
107 niro 1248 }
108    
109 niro 1257 # get_fluxbox_menuitem
110     get_fluxbox_menuitem()
111 niro 1248 {
112 niro 1257 local i
113     local item
114    
115     for i in $(find ${MCORE_CONFIG_PATH}/fluxbox/menu -type f | sort)
116     do
117     item="${item} $(basename ${i})"
118     done
119    
120     mecho "${item}"
121 niro 1248 }
122    
123 niro 1257 help_fluxbox_theme()
124 niro 1248 {
125 niro 1257 mecho "get fluxbox.theme [method]"
126     mecho " Displays current installed or system-wide available themes."
127     mecho " Methods:"
128     mecho " system - shows systemwide available themes"
129     mecho " current - shows current selected theme"
130     mecho
131     mecho "set fluxbox.theme [theme]"
132     mecho " Sets a default theme for fluxbox."
133     }
134 niro 1248
135 niro 1257 set_fluxbox_theme()
136     {
137     local theme="$1"
138     local stylesdir="/usr/share/fluxbox/styles"
139    
140     [[ -z ${theme} ]] && help_fluxbox_theme && return 1
141     [[ ! -x $(which fluxbox-remote) ]] && eecho "fluxbox-remote missing! Aborted" && return 1
142    
143     if [[ -e ${stylesdir}/${theme} ]]
144 niro 1248 then
145 niro 1257 x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'"
146     else
147     eechoe "Theme '${theme}' does not exist!"
148 niro 1248 fi
149 niro 1257 }
150 niro 1248
151 niro 1257 get_fluxbox_theme()
152     {
153     local method="$1"
154     local stylesdir="/usr/share/fluxbox/styles"
155     local value
156     local i
157    
158     [[ -z ${method} ]] && help_fluxbox_theme && return 1
159    
160     case "${method}" in
161     system)
162     for i in $(find ${stylesdir} -mindepth 1 -maxdepth 1 | sort)
163     do
164     value="${value} $(basename ${i})"
165     done
166     mecho "${value}"
167     ;;
168    
169     current)
170     value=$(grep -i '^session.stylefile' ${MCORE_UNPRIV_HOME}/.fluxbox/init | sed 's:.*/\(.*\):\1:')
171     mecho "${value}"
172     ;;
173     *) help_fluxbox_theme && return 1 ;;
174     esac
175 niro 1248 }