personal dotfiles: my Hyprland config
Diffstat (limited to '.config/sxmo/userscripts/appstore.sh')
-rwxr-xr-x.config/sxmo/userscripts/appstore.sh200
1 files changed, 0 insertions, 200 deletions
diff --git a/.config/sxmo/userscripts/appstore.sh b/.config/sxmo/userscripts/appstore.sh
deleted file mode 100755
index 0743df4..0000000
--- a/.config/sxmo/userscripts/appstore.sh
+++ /dev/null
@@ -1,200 +0,0 @@
-#!/bin/sh
-# Author: Zach DeCook <zachdecook@librem.one>
-# License: MIT
-. sxmo_hook_icons.sh
-
-## Data
-
-ID_LIKE="$(sh -c '. /etc/os-release; echo "${ID_LIKE:-$ID}"')"
-
-# Data comes from the apps hook.
-# Outputs $icon_name\tbin_name
-listApps(){
- grep ^write_line_app /usr/share/sxmo/default_hooks/*apps* | tr -d '"'| awk '{print $3 "\t" $2}'
-}
-# Categories should have 4-12 apps.
-# These are the menu categories, with the icons which go with them.
-Menus="$icon_msg Messaging \(grp\|msg\|tgm\)
-$icon_glb Browsing \(ffx\|flk\|glb\)
-$icon_rss News \(red\|rss\)
-$icon_eml Email eml
-$icon_edt Editing \(edt\|vim\)
-$icon_mus Multimedia \(cam\|mic\|mus\|mvi\)
-$icon_dir Files dir
-$icon_trm Terminal trm
-$icon_map Maps \(gps\|map\)
-$icon_itm Misc \(and\|bok\|cfg\|chs\|clc\|clk\|grd\|img\|inf\|itm\|lck\|rld\|str\)
-exit"
-
-## Functions
-
-bin2launch(){
- xargs -I{} grep "^write_line_app {} " /usr/share/sxmo/default_hooks/*apps* |grep -o '"[^"]*"$' |xargs -I{} sh -c 'eval echo {}'
-}
-
-pkgInfo(){
- pkg="$1"
- case "$ID_LIKE" in
- "alpine")
- apk info -dws "$pkg" | grep -v '^$' | grep -v ' webpage:' | grep -v 'installed size:'
- bins="$(apk info -L "$pkg" |grep ^usr/bin/ | cut -d/ -f3)"
- if test -n "$bins"; then
- echo "$bins" | bin2launch | sed 's/^/Launch /g'
- fi
- ;;
- "debian")
- # apt has an unstable cli
- # lines starting with a space are additional description lines
- apt info "$pkg" | grep '\(Package\|Version\|Description\| \|\)' | sed 's/: /\t/g' | cut -f2
- ;;
- "arch")
- # -Si means remote information
- pacman -Si "$pkg" | grep '^\(Name\|Version\|Description\|URL\)' | sed 's/ : /\t/g' | cut -f2
- ;;
- *)
- printf "I don't know how to get package information in '%s' distros\n" "$ID_LIKE"
- ;;
- esac
-}
-pkgInstall(){
- pkg="$1"
- case "$ID_LIKE" in
- "alpine")
- sxmo_terminal.sh doas apk add "$pkg"
- ;;
- "debian")
- sxmo_terminal.sh doas apt-get install "$pkg"
- ;;
- "arch")
- sxmo_terminal.sh doas pacman -Sy "$pkg"
- ;;
- *)
- printf "I don't know how to install packages in '%s'.\n" "$ID_LIKE"
- ;;
- esac
-}
-pkgRemove(){
- pkg="$1"
- case "$ID_LIKE" in
- "alpine")
- sxmo_terminal.sh doas apk del "$pkg"
- ;;
- "debian")
- sxmo_terminal.sh doas apt-get remove "$pkg"
- ;;
- "arch")
- sxmo_terminal.sh doas pacman -R "$pkg"
- ;;
- *)
- printf "I don't know how to install packages in '%s'.\n" "$ID_LIKE"
- ;;
- esac
-}
-
-
-# Takes in bin names and returns package names which provide those.
-pkgNames(){
- case "$ID_LIKE" in
- "alpine")
- sed 's/^/cmd:/g' | xargs -r apk search -xqa | uniq
- ;;
- "debian")
- if command -v apt-file; then
- #in my experience, apt-file is really slow...
- xargs -r -I{} apt-file find -Fl /usr/bin/{}
- # sed s'@^@/usr/bin/@g' | apt-file find -Flf /dev/stdin
- else
- printf "apt-file must be installed (and updated) to find packages which provide a certain bin.\n" > /dev/stderr
- fi
- ;;
- "arch")
- sed 's@^@/usr/bin/@g' | xargs -r pacman -Fq | cut -d/ -f2
- ;;
- *)
- printf "I don't know how to find package names from commands in '%s'.\n" "$ID_LIKE" > /dev/stderr
- ;;
- esac
-}
-
-
-pkgInstalled(){
- case "$ID_LIKE" in
- "alpine")
- tee /tmp/appstoreapps | xargs -r apk info -e |sed 's/.\+/✅ \0/g' | cat - /tmp/appstoreapps |sed 's/^[a-z]/🟩 \0/g'| sort -i |uniq -f1
- ;;
- *)
- cat - |sed 's/.\+/❓ \0/g'
- printf "I don't know how to check installed status from commands in '%s'.\n" "$ID_LIKE" > /dev/stderr
- ;;
- esac
-}
-
-## Menus
-
-topMenu(){
- sel="$(printf '%s' "$Menus" | cut -f1 | sxmo_dmenu.sh -i -p "App Store" |cut -d' ' -f2)"
- if ! test "$sel" || test "$sel" = "exit"; then
- exit 0
- fi
- menuName "$sel"
-}
-
-menuName(){
- name="$1"
- typ="$(echo "$Menus" | grep "$name " | cut -f2)"
- # shellcheck disable=SC2016
- grep='^\$icon_'"$typ"' '
- pkg="$(listApps | grep "$grep" |cut -f2|pkgNames|pkgInstalled|awk 'BEGIN{print ".."} ($0){print} END{print "exit"}'|sxmo_dmenu.sh -i -p "$name"|cut -d' ' -f2)"
- if test "$pkg" = "exit" || ! test "$pkg"; then
- exit
- elif test "$pkg" = ".."; then
- topMenu
- else
- pkgMenu "$pkg" "$name"
- fi
-}
-
-pkgMenu(){
- title="$(printf '%s' "$1"|cut -f1)"
- menu="..
-install
-uninstall
-$(pkgInfo "$1")
-exit"
- while true; do
- sel="$(printf '%s\n' "$menu"|sxmo_dmenu.sh -p "$title")"
- case "$sel" in
- "install")
- pkgInstall "$1"
- ;;
- "uninstall")
- pkgRemove "$1"
- ;;
- "..")
- menuName "$2"
- return
- ;;
- "exit"|"")
- exit
- ;;
- "Launch "*)
- ${sel#???????}
- ;;
- *"://"*)
- sxmo_open.sh "$sel"
- exit
- ;;
- *)
- notify-send "$sel"
- ;;
- esac
- done
-}
-
-## Execution
-if test -n "$1"; then
- $1
-else
- topMenu
-fi
-