hide 922 B

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