Commit 330bb09c580876c434b02ccf39d9fd378163cd96

Authored by Silvan Calarco
1 parent 29dcce2550
Exists in master

kickoffcfg: support user mode and display current favorites when called with no arguments

Showing 1 changed file with 12 additions and 5 deletions Side-by-side Diff

1 1 #!/bin/sh
  2 +if [ `id -u` -eq 0 ]; then
  3 + CONFDIR=/opt/kde/share/config
  4 +else
  5 + CONFDIR=~/.kde4/share/config
  6 +fi
  7 +FAVORITES=`/opt/kde/bin/kreadconfig --file $CONFDIR/kickoffrc --group Favorites --key FavoriteURLs 2>/dev/null`
  8 +
2 9 [ "$1" -a "$2" ] || {
3 10 echo "KDE4 kickoff configuration tool"
4 11 echo
5 12 echo "Usage: kickoffcfg {--add-favorite|--del-favorite} /path/to/desktopfile.desktop"
6 13 echo
  14 + echo "Current favorites:"
  15 + echo $FAVORITES
7 16 exit 1
8 17 }
9 18  
10   -FAVORITES=`/opt/kde/bin/kreadconfig --file /opt/kde/share/config/kickoffrc --group Favorites --key FavoriteURLs 2>/dev/null`
11   -
12 19 if [ "$1" = "--add-favorite" ]; then
13 20 # ADD
14 21 echo "$FAVORITES" | grep $2 >/dev/null || {
15 22  
16 23  
... ... @@ -17,15 +24,15 @@
17 24 else
18 25 FAVORITES="$2"
19 26 fi
20   - /opt/kde/bin/kwriteconfig --file /opt/kde/share/config/kickoffrc --group Favorites --key FavoriteURLs $FAVORITES
  27 + /opt/kde/bin/kwriteconfig --file $CONFDIR/kickoffrc --group Favorites --key FavoriteURLs $FAVORITES
21 28 }
22 29 elif [ "$1" = "--del-favorite" ]; then
23 30 # DELETE
24 31 MODFAVORITES=`echo "$FAVORITES" | sed "s|$2||" | sed "s| ,||" | sed "s|,,|,|"`
25 32 if [ ! "$MODFAVORITES" ]; then
26   - /opt/kde/bin/kwriteconfig --file /opt/kde/share/config/kickoffrc --group Favorites --key FavoriteURLs ''
  33 + /opt/kde/bin/kwriteconfig --file $CONFDIR/kickoffrc --group Favorites --key FavoriteURLs ''
27 34 elif [ "$FAVORITES" != "$MODFAVORITES" ]; then
28   - /opt/kde/bin/kwriteconfig --file /opt/kde/share/config/kickoffrc --group Favorites --key FavoriteURLs $MODFAVORITES
  35 + /opt/kde/bin/kwriteconfig --file $CONFDIR/kickoffrc --group Favorites --key FavoriteURLs $MODFAVORITES
29 36 fi
30 37 else
31 38 echo "Invalid option $1; aborting."