Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/modules/fluxbox/fluxbox.client.class.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2269 - (hide annotations) (download)
Tue Jan 14 10:34:57 2014 UTC (10 years, 4 months ago) by niro
File size: 3034 byte(s)
-use global argv arrays GLOBAL_ARGV and CLASS_ARGV to fix whitespace issues with the read cmd. escaping works with this now. every class must use the CLASS_ARGV array for arguments
1 niro 1248 # $Id$
2    
3 niro 1257 # todo wallpaper?
4    
5 niro 1248 # what does this plugin provide?
6     provide fluxbox
7    
8 niro 1257 help_fluxbox_menuitem()
9 niro 1248 {
10 niro 1257 mecho "get fluxbox.menuitem"
11     mecho " Shows all custom added menuitems of fluxbox."
12     mecho
13     mecho "set fluxbox.menuitem [action] [name] [exec] [workdir] [icon]"
14     mecho " Adds or deletes a fluxbox menu entry."
15     mecho " Actions:"
16     mecho " add - adds a menuitem"
17     mecho " del - deletes a menuitem"
18     mecho
19     mecho " name - menu entry name"
20     mecho " exec - executable to start"
21     mecho " workdir - working directory for the executable - optional"
22     mecho " icon - pixmap icon of the entry - optional"
23     mecho
24     mecho " If no [name] given, all entries will be deleted."
25 niro 1248 }
26    
27 niro 1257 # set_fluxbox_menuitem $name $exec $workdir $icon
28     set_fluxbox_menuitem()
29 niro 1248 {
30 niro 2269 local action="${CLASS_ARGV[0]}"
31     local name="${CLASS_ARGV[1]}"
32     local exec="${CLASS_ARGV[2]}"
33     local workdir="${CLASS_ARGV[3]}"
34     local icon="${CLASS_ARGV[4]}"
35 niro 1253 local CONFIG
36 niro 1248
37 niro 1257 [[ -z ${action} ]] && help_fluxbox_menuitem && return 1
38 niro 1248
39 niro 1257 case "${action}" in
40     add)
41     [[ -z ${name} ]] && help_fluxbox_menuitem && return 1
42     [[ -z ${exec} ]] && help_fluxbox_menuitem && return 1
43 niro 2013 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/${name}"
44 niro 1257 clearconfig
45     addconfig "[exec] (${name}) {${exec}}"
46     ;;
47     del)
48 niro 2013 if [[ -f ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]]
49 niro 1257 then
50 niro 2013 rm ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu/"${name}"
51 niro 1257 elif [[ -z ${name} ]]
52     then
53     # delete all items
54 niro 2027 find ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu -type f | xargs --no-run-if-empty rm
55 niro 1257 fi
56     ;;
57     *)
58     help_fluxbox_menuitem && return 1
59     ;;
60     esac
61 niro 1253
62 niro 1248 # rebuild the menu now
63 niro 2154 fluxbox-rebuild-menu
64 niro 1248 }
65    
66 niro 1257 # get_fluxbox_menuitem
67     get_fluxbox_menuitem()
68 niro 1248 {
69 niro 2014 list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/fluxbox/menu
70 niro 1248 }
71    
72 niro 1257 help_fluxbox_theme()
73 niro 1248 {
74 niro 1257 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 niro 1248
84 niro 1257 set_fluxbox_theme()
85     {
86 niro 2269 local theme="${CLASS_ARGV[0]}"
87 niro 2152 local stylesdir="@@DATADIR@@/fluxbox/styles"
88 niro 1257
89     [[ -z ${theme} ]] && help_fluxbox_theme && return 1
90 niro 2153 [[ ! -x $(type -P fluxbox-remote) ]] && eecho "fluxbox-remote missing! Aborted" && return 1
91 niro 1257
92     if [[ -e ${stylesdir}/${theme} ]]
93 niro 1248 then
94 niro 1257 x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'"
95     else
96 niro 2028 eecho "Theme '${theme}' does not exist!"
97 niro 1248 fi
98 niro 1257 }
99 niro 1248
100 niro 1257 get_fluxbox_theme()
101     {
102 niro 2269 local method="${CLASS_ARGV[0]}"
103 niro 2152 local stylesdir="@@DATADIR@@/fluxbox/styles"
104 niro 1257 local value
105     local i
106    
107     [[ -z ${method} ]] && help_fluxbox_theme && return 1
108    
109     case "${method}" in
110     system)
111 niro 2014 list_files_in_directory -type d -mindepth 1 -maxdepth 1 ${MROOT}/${stylesdir}
112 niro 1257 ;;
113    
114     current)
115 niro 2013 value=$(grep -i '^session.stylefile' ${MROOT}/${MCORE_UNPRIV_HOME}/.fluxbox/init | sed 's:.*/\(.*\):\1:')
116 niro 1642 rvecho "${value}"
117 niro 1257 ;;
118     *) help_fluxbox_theme && return 1 ;;
119     esac
120 niro 1248 }