Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1256 by niro, Wed Feb 2 21:19:48 2011 UTC revision 1257 by niro, Fri Feb 4 19:55:56 2011 UTC
# Line 1  Line 1 
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    
# Line 46  helper_rebuild_fluxbox_menu() Line 48  helper_rebuild_fluxbox_menu()
48   addconfig   addconfig
49  }  }
50    
51  help_fluxbox_addmenuitem()  help_fluxbox_menuitem()
52  {  {
53   mecho "set fluxbox.addmenuitem [name] [exec] [workdir] [icon]"   mecho "get fluxbox.menuitem"
54   mecho " adds a fluxbox menu entry"   mecho " Shows all custom added menuitems of fluxbox."
55   mecho "  name    - menu entry name"   mecho
56   mecho "  exec    - executable to start"   mecho "set fluxbox.menuitem [action] [name] [exec] [workdir] [icon]"
57   mecho "  workdir - working directory for the executable - optional"   mecho " Adds or deletes a fluxbox menu entry."
58   mecho "  icon    - pixmap icon of the entry - optional"   mecho " Actions:"
59  }   mecho "   add     - adds a menuitem"
60     mecho "   del     - deletes a menuitem"
61  # set_fluxbox_addmenuitem $name $exec $workdir $icon   mecho
62  set_fluxbox_addmenuitem()   mecho "   name    - menu entry name"
63  {   mecho "   exec    - executable to start"
64   local name="$1"   mecho "   workdir - working directory for the executable - optional"
65   local exec="$2"   mecho "   icon    - pixmap icon of the entry - optional"
66   local workdir="$3"   mecho
67   local icon="$4"   mecho " If no [name] given, all entries will be deleted."
68    }
69    
70    # set_fluxbox_menuitem $name $exec $workdir $icon
71    set_fluxbox_menuitem()
72    {
73     local action="$1"
74     local name="$2"
75     local exec="$3"
76     local workdir="$4"
77     local icon="$5"
78   local CONFIG   local CONFIG
79    
80   [[ -z ${name} ]] && help_session_addmenuitem && return 1   [[ -z ${action} ]] && help_fluxbox_menuitem && return 1
  [[ -z ${exec} ]] && help_session_addmenuitem && return 1  
81    
82   CONFIG="${MCORE_CONFIG_PATH}/fluxbox/menu/${name}"   case "${action}" in
83   clearconfig   add)
84   addconfig "[exec] (${name}) {${exec}}"   [[ -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    
105   # rebuild the menu now   # rebuild the menu now
106   helper_rebuild_fluxbox_menu   helper_rebuild_fluxbox_menu
107  }  }
108    
109  help_fluxbox_delmenuitem()  # get_fluxbox_menuitem
110    get_fluxbox_menuitem()
111    {
112     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    }
122    
123    help_fluxbox_theme()
124  {  {
125   mecho "set session.delmenuitem [name]"   mecho "get fluxbox.theme [method]"
126   mecho " Deletes a fluxbox menu entry."   mecho " Displays current installed or system-wide available themes."
127   mecho "  name - menu entry name"   mecho " Methods:"
128   mecho " If no [name] given, all entries are deleted."   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    
135  # set_fluxbox_delmenuitem [$name]  set_fluxbox_theme()
 set_fluxbox_delmenuitem()  
136  {  {
137   local name="$1"   local theme="$1"
138     local stylesdir="/usr/share/fluxbox/styles"
139    
140   if [[ -f ${MCORE_CONFIG_PATH}/fluxbox/menu/${name} ]]   [[ -z ${theme} ]] && help_fluxbox_theme && return 1
141   then   [[ ! -x $(which fluxbox-remote) ]] && eecho "fluxbox-remote missing! Aborted" && return 1
142   rm ${MCORE_CONFIG_PATH}/fluxbox/menu/${name}  
143   elif [[ -z ${name} ]]   if [[ -e ${stylesdir}/${theme} ]]
144   then   then
145   # delete all items   x11runas "fluxbox-remote 'SetStyle ${stylesdir}/${theme}'"
146   rm ${MCORE_CONFIG_PATH}/fluxbox/menu/*   else
147     eechoe "Theme '${theme}' does not exist!"
148   fi   fi
149    }
150    
151   # rebuild the menu now  get_fluxbox_theme()
152   helper_rebuild_fluxbox_menu  {
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  }  }

Legend:
Removed from v.1256  
changed lines
  Added in v.1257