Add list and remove functionalities.

This commit is contained in:
lemniskett 2020-12-16 14:42:26 +07:00
parent 6d05f2f7e1
commit 3fda848d84

View File

@ -27,7 +27,10 @@ cat << EOF
USAGE: $0 <arguments> USAGE: $0 <arguments>
OPTIONS: OPTIONS:
-i, --install URL Installs a desktop entry in /usr/share/applications -i, --install FILE Installs desktop entries in /usr/share/applications
-r, --remove FILE Removes desktop entries in ~/.local/share/applications/archbox
-l, --list List available desktop entries
-s, --list-installed List installed desktop entries
-h, --help Displays this help message -h, --help Displays this help message
EOF EOF
@ -36,23 +39,54 @@ EOF
case $1 in case $1 in
-i|--install) -i|--install)
install_desktop ${@:2} install_desktop ${@:2}
;; ;;
-r|--remove)
eval rm ~/.local/share/applications/archbox/{$selected_entry}
;;
-h|--help) -h|--help)
help_text help_text
;; ;;
-*) -l|--list)
err "Unknown option: $1" archbox ls -1 --color=none /usr/share/applications
;; ;;
-s|--list-installed)
ls -1 --color=none ~/.local/share/applications/archbox
;;
*) *)
checkdep zenity checkdep zenity
checkdep sed checkdep sed
list_desktop="$(archbox ls --color=none -1 /usr/share/applications)" action="$(zenity --list --radiolist --title 'Archbox Desktop Manager' \
zenity_entry="$(echo $list_desktop | sed 's/\ /\ FALSE\ /g')" --height=200 --width=450 --column 'Select' --column 'Action' \
selected_entry=$(zenity --list --checklist --height=500 --width=450 \ --text 'What do you want to do?' \
--title="Archbox Desktop Manager" \ FALSE 'Install desktop entries' FALSE 'Remove desktop entries')"
--text "Select .desktop entries those you want to install" \ case $action in
--column "Select" --column "Applications" \ 'Install desktop entries')
FALSE $zenity_entry | sed 's/|/\ /g') list_desktop="$(archbox ls --color=none -1 /usr/share/applications)"
install_desktop $selected_entry zenity_entry="$(echo $list_desktop | sed 's/\ /\ FALSE\ /g')"
selected_entry=$(zenity --list --checklist --height=500 --width=450 \
--title="Archbox Desktop Manager" \
--text "Select .desktop entries those you want to install" \
--column "Select" --column "Applications" \
FALSE $zenity_entry | sed 's/|/\ /g')
[[ -z $selected_entry ]] && exit 1
install_desktop $selected_entry
exit 0
;;
'Remove desktop entries')
list_desktop="$(ls --color=none -1 ~/.local/share/applications/archbox)"
[[ -z $list_desktop ]] && zenity --info --title "Archbox Desktop Manager" \
--text "No .desktop files installed" --width=300 && exit 1
zenity_entry="$(echo $list_desktop | sed 's/\ /\ FALSE\ /g')"
selected_entry=$(zenity --list --checklist --height=500 --width=450 \
--title="Archbox Desktop Manager" \
--text "Select .desktop entries those you want to remove" \
--column "Select" --column "Applications" \
FALSE $zenity_entry | sed 's/|/\,/g')
[[ -z $selected_entry ]] && exit 1
eval rm ~/.local/share/applications/archbox/{$selected_entry}
exit $?
;;
esac
exit 1
;; ;;
esac esac