# HG changeset patch # User Christophe Lincoln # Date 1235252038 -3600 # Node ID 8c4b3f6b1bd0b9c54f723bf908207b883e3fd7ab # Parent c90e38d22ae6944fcef7fda64a42f4c530010e04 desktopbox: Add autostart (GUI to enable/disable apps started with Openbox) diff -r c90e38d22ae6 -r 8c4b3f6b1bd0 rootfs/usr/share/applications/desktopbox-autostart.desktop --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rootfs/usr/share/applications/desktopbox-autostart.desktop Sat Feb 21 22:33:58 2009 +0100 @@ -0,0 +1,7 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Auto started applications +Icon=preferences-system-session +Exec=desktopbox autostart +Type=Application +Categories=Settings;DesktopSettings;GTK; diff -r c90e38d22ae6 -r 8c4b3f6b1bd0 tinyutils/desktopbox --- a/tinyutils/desktopbox Fri Feb 20 01:40:30 2009 +0100 +++ b/tinyutils/desktopbox Sat Feb 21 22:33:58 2009 +0100 @@ -9,6 +9,9 @@ # Glade XML file path. GLADE_XML=/usr/share/slitaz-tools/glade +# Export script path and other if needed so we can use them in 'quote'. +export BIN=$0 +export AUTOSTART_SCRIPT=$HOME/.config/openbox/autostart.sh # Standard directories. mkdir -p $HOME/Desktop $HOME/.local/share/applications @@ -68,10 +71,88 @@ calendar Display a calendar under mouse pointer. notify Display a notification message (center/no decoration). Ex: `basename $0` notify \"Message to display\" 4 + autostart Manage autostarted applications with Openbox. logout Prompt for X session exit or system halt/reboot.\n" } +# Openbox autostart functions, first column is used for icon +autostart_list() +{ + # Enabled + for app in `cat $AUTOSTART_SCRIPT | grep ^[a-z] | awk '{ print $1 }'` + do + comment=`grep -B 1 "^$app" $AUTOSTART_SCRIPT | grep '^# ' | sed s/'#'//` + [ -x /usr/bin/$app ] && echo "go-next | $app | $comment" + done + # Disabled + for app in `cat $AUTOSTART_SCRIPT | grep ^#[a-z] | awk '{ print $1 }'` + do + comment=`grep -B 1 "^$app" $AUTOSTART_SCRIPT | grep '^# ' | sed s/'#'//` + app=${app#\#} + [ -x /usr/bin/$app ] && echo "stop | $app | $comment" + done +} + +# Enable or disbale autostarted applications. +autostart_actions() +{ + if grep -q "^$APPLICATION" $AUTOSTART_SCRIPT; then + sed -i s/"^$APPLICATION"/"\#$APPLICATION"/ $AUTOSTART_SCRIPT + else + sed -i s/"^\#$APPLICATION"/"$APPLICATION"/ $AUTOSTART_SCRIPT + fi +} + +add_autostarted_app() +{ + if ! grep -q "^$NEW_APP" $AUTOSTART_SCRIPT; then + NEW_APP=`echo $NEW_APP | sed s/'&'/''/` + echo "" >> $AUTOSTART_SCRIPT + echo "# $NEW_COMMENT" >> $AUTOSTART_SCRIPT + echo "$NEW_APP &" >> $AUTOSTART_SCRIPT + fi +} + +add_autostarted_app_box() +{ + export ADD_AUTO_START_BOX=' + + + + + + + + + + + NEW_APP + + + + + + + + NEW_COMMENT + + + + + + + +' + gtkdialog --center --program=ADD_AUTO_START_BOX +} + # Box commands. + case $1 in new-folder) # Create a directory on the ~/Desktop. @@ -288,6 +369,51 @@ pid=`ps | grep NOTIFY_BOX | awk '{ print $1 }'` kill $pid 2>/dev/null exit 0 ;; + autostart) + # Autostarted apps management. Functions are used for input + # and actions + export DESKTOP_DIALOG=' + + + + 540200 + APPLICATION + + $BIN autostart_list + $BIN autostart_actions + refresh:APPLICATION + + + + + + + + + + +' + ;; + *_*) + # Exec all function called by args (must have an underscore). + $1 + exit 0 ;; *) # Usage if executed from cmdline. #