Created
May 25, 2014 09:31
-
-
Save hilbix/f468fcbb15c3f68670d8 to your computer and use it in GitHub Desktop.
Wrapper around desktop-file-install to edit Ubuntu launchers (`.desktop` files aka shortcuts)
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 | |
LOC="$HOME/.local/share/applications" | |
OOPS() | |
{ | |
echo "OOPS: $*" >&2 | |
exit 1 | |
} | |
edit() | |
{ | |
f="$1" | |
case "$f" in | |
*..*) OOPS "illegal path: $1";; | |
*/applications/*/*) OOPS "wrong path: $1";; | |
*/applications/*) ;; | |
*/*) OOPS "wrong path: $1";; | |
*) f="$LOC/${f%.desktop}.desktop"; [ -s "$f" ] || { ls -al "$LOC" >&2; OOPS "not found: $1"; };; | |
esac | |
[ -s "$f" ] || OOPS "unknown: $1" | |
TMP="$(mktemp -d)" | |
n="$TMP/${f##*/}" | |
cp -f "$f" "$n" | |
while vim "$n" | |
echo "$?: $n" | |
desktop-file-install --delete-original --dir="`dirname "$f"`" "$n" | |
rmdir "$TMP" && return | |
read | |
do | |
: | |
done | |
} | |
edit "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to http://askubuntu.com/a/447703 and
desktop-file-install
the changes update immediately in Compiz.BUGs:
.desktop
file is deleted before install of the new one. If the new one contains errors, the previous version vanishes unseen. You will find it in the/tmp/
directory somewhere (but/tmp/
is meant to be erased on reboots!) in such a case. This is a design flaw.return
after reading the messages) until all errors in the.desktop
file are fixed. If you want to break the loop, press^D
(EOF
) after leaving the editor, but this will kill the original.desktop
file, see previous point.Missing features:
License:
How to add such a
.desktop
file to the Ubuntu launcher if it is missing:How to use this:
vim
. If you like another editor, replace this. Perhaps replacevim
in the script witheditor
./usr/share/applications/*.desktop
files if you run itsudo
(never been tested!), but you shouldn't.~/.local/share/applications/
first and edit them there. But this, again, has not been tested.