2011-06-02 15:59:13 +02:00
|
|
|
#!/bin/sh
|
2016-05-19 01:08:08 +02:00
|
|
|
if [ `id -u` -eq 0 ]; then
|
|
|
|
CONFDIR=/opt/kde/share/config
|
|
|
|
else
|
|
|
|
CONFDIR=~/.kde4/share/config
|
|
|
|
fi
|
|
|
|
FAVORITES=`/opt/kde/bin/kreadconfig --file $CONFDIR/kickoffrc --group Favorites --key FavoriteURLs 2>/dev/null`
|
|
|
|
|
2011-06-02 15:59:13 +02:00
|
|
|
[ "$1" -a "$2" ] || {
|
|
|
|
echo "KDE4 kickoff configuration tool"
|
|
|
|
echo
|
|
|
|
echo "Usage: kickoffcfg {--add-favorite|--del-favorite} /path/to/desktopfile.desktop"
|
|
|
|
echo
|
2016-05-19 01:08:08 +02:00
|
|
|
echo "Current favorites:"
|
|
|
|
echo $FAVORITES
|
2011-06-02 15:59:13 +02:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$1" = "--add-favorite" ]; then
|
|
|
|
# ADD
|
|
|
|
echo "$FAVORITES" | grep $2 >/dev/null || {
|
|
|
|
if [ "$FAVORITES" ]; then
|
|
|
|
FAVORITES="$FAVORITES,$2"
|
|
|
|
else
|
|
|
|
FAVORITES="$2"
|
|
|
|
fi
|
2016-05-19 01:08:08 +02:00
|
|
|
/opt/kde/bin/kwriteconfig --file $CONFDIR/kickoffrc --group Favorites --key FavoriteURLs $FAVORITES
|
2011-06-02 15:59:13 +02:00
|
|
|
}
|
|
|
|
elif [ "$1" = "--del-favorite" ]; then
|
|
|
|
# DELETE
|
|
|
|
MODFAVORITES=`echo "$FAVORITES" | sed "s|$2||" | sed "s| ,||" | sed "s|,,|,|"`
|
|
|
|
if [ ! "$MODFAVORITES" ]; then
|
2016-05-19 01:08:08 +02:00
|
|
|
/opt/kde/bin/kwriteconfig --file $CONFDIR/kickoffrc --group Favorites --key FavoriteURLs ''
|
2011-06-02 15:59:13 +02:00
|
|
|
elif [ "$FAVORITES" != "$MODFAVORITES" ]; then
|
2016-05-19 01:08:08 +02:00
|
|
|
/opt/kde/bin/kwriteconfig --file $CONFDIR/kickoffrc --group Favorites --key FavoriteURLs $MODFAVORITES
|
2011-06-02 15:59:13 +02:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Invalid option $1; aborting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
exit 0
|