12345678910111213141516171819202122232425262728293031323334 |
- #!/bin/bash
- str="NoDisplay=true"
- dst="$HOME/.local/share/applications"
- src="/usr/share/applications"
- printf "%s\n" "Hide app menu items (.desktop files in $src)" "(and customise them)"
- cd "$src" || exit 1
- PS3="
- Choice: "
- select file in $(for i in *.desktop; do printf "%s " "${i%.*}"; done)
- do
- file="$file.desktop"
- echo "File: $src/$file"
- read -rp "Do you want to copy it to ~${dst#$HOME}? " x
- [ "$x" = y ] && cp "$file" "$dst/"
- grep -qi "^[[:blank:]]*$str[[:space:]]*" "$file" ||\
- devel-su sed -i "s/\[[Dd]esktop [Ee]ntry\]/\[Desktop Entry\]\n$str/" "$src/$file"
- echo "Original menu item is now hidden"
- [ -r "$dst/$file" ] || continue
- read -rp "Do you want to edit it in ~${dst#$HOME}? " x
- [ "$x" = y ] && nano "$dst/$file"
- # Sth like this is necessary to force lipstick to use the edited version:
- mv "$dst/$file" "$dst/${file%.desktop}.$(date +%s).desktop"
- done
|