Created
April 19, 2021 19:55
-
-
Save agail/fc2bab6fd4e6cafe0eb5b94da0e4b5bf to your computer and use it in GitHub Desktop.
Manage Gnome3 favorites (add, list remove)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# List / add / remove application favourites to gnome3 | |
# Works with Ubuntu 18.04, 20.04 LTS | |
# | |
opt=($*) | |
favourites="/org/gnome/shell/favorite-apps" | |
add () { | |
local app=$1 | |
dconf write ${favourites} \ | |
"$(dconf read ${favourites} | \ | |
sed "s/, '${app}'//g; s/'${app}'//g" | \ | |
sed -e "s/]$/, '${app}']/")" | |
} | |
list () { | |
echo | |
dconf read /org/gnome/shell/favorite-apps | \ | |
sed "s/[][',]\|.desktop/ /g;s/ /\n/g" | |
} | |
remove () { | |
local app=$1 | |
dconf write ${favourites} "$(dconf read ${favourites} | \ | |
sed "s/'${app}', //g; s/, '${app}'//g")" | |
} | |
syntax () { | |
cat << EOFH | |
${0##*/} [option] deskop-file.desktop | |
options add | |
list | |
remove | |
EOFH | |
} | |
case ${opt[0]} in | |
add) if [ $# -lt 2 ]; then syntax; else add ${opt[1]}; fi ;; | |
list) list ;; | |
remove) if [ $# -lt 2 ]; then syntax; else remove ${opt[1]}; fi ;; | |
*) syntax ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment