1
1
Fork 0

menu.sh: refactor with argc

Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
Myned 2024-11-23 21:20:44 -06:00
parent 75b53c52b6
commit 228d238744
Signed by: myned
GPG key ID: C7224454F7881A34
2 changed files with 86 additions and 52 deletions

View file

@ -113,6 +113,7 @@ in {
sway sway
]) ])
(bash "menu" [ (bash "menu" [
argc
coreutils coreutils
hyprland hyprland
jq jq

View file

@ -1,60 +1,93 @@
#! /usr/bin/env bash #! /usr/bin/env bash
# Menu wrapper # @describe Wrapper for menu commands
#?? menu #
# https://github.com/sigoden/argc
command=walker # @meta combine-shorts
while (("$#" > 0)); do
case "$1" in
--applications)
command="walker --modules applications"
;;
--calculator)
command="walker --modules calc"
;;
--clipboard)
command="walker --modules clipboard"
;;
--files)
command="walker --modules finder"
;;
--input)
command="walker --dmenu"
;;
--networks)
command="networkmanager_dmenu"
;;
--passwords)
command="rofi-rbw"
;;
--runner)
command="walker --modules runner"
;;
--search)
command="walker --modules websearch"
;;
--ssh)
command="walker --modules ssh"
;;
--unicode)
command="walker --modules emojis"
;;
--windows)
command="walker --modules windows"
;;
--)
shift
command+=" $*"
break
;;
esac
shift
done
# HACK: Restart service to close existing menu # HACK: Restart service to close existing menu
if hyprctl -j layers | jq -e '.[][][][] | select(.namespace == "walker")'; then if hyprctl -j layers | jq -e '.[][][][] | select(.namespace == "walker")'; then
systemctl --user restart walker.service systemctl --user restart walker.service
else exit
$command
fi fi
# @cmd Launch menu without modules
# @meta default-subcommand
menu() {
walker
}
# @cmd Launch menu with application module
# @alias a,ap,app,appl,appli,applic,applica,applicat,applicati,applicatio,applications
application() {
walker --modules applications
}
# @cmd Launch menu with calculator module
# @alias c,ca,calc,calcu,calcul,calcula,calculat,calculato
calculator() {
walker --modules calc
}
# @cmd Launch menu with clipboard module
# @alias cl,cli,clip,clipb,clipbo,clipboa,clipboar
clipboard() {
walker --modules clipboard
}
# @cmd Launch menu with emoji module
# @alias e,em,emo,emoj,emot,emote
emoji() {
walker --modules emojis
}
# @cmd Launch menu with file module
# @alias f,fi,fil,files
file() {
walker --modules finder
}
# @cmd Launch menu with input module
# @alias i,in,inp,inpu,d,dm,dme,dmen,dmenu
input() {
walker --dmenu
}
# @cmd Launch menu via networkmanager_dmenu
# @alias n,ne,net,netw,netwo,networks
network() {
networkmanager_dmenu
}
# @cmd Launch menu via rofi-rbw
# @alias p,pa,pas,pass,passw,passwo,passwor,passwords
password() {
rofi-rbw
}
# @cmd Launch menu with search module
# @alias s,se,sea,sear,searc
search() {
walker --modules search
}
# @cmd Launch menu with shell module
# @alias sh,she,shel,co,com,comm,comma,comman,command,commands
shell() {
walker --modules runner
}
# @cmd Launch menu with ssh module
# @alias ss
ssh() {
walker --modules ssh
}
# @cmd Launch menu with wm module
# @alias w,wi,win,wind,windo,window,windows
wm() {
walker --modules windows
}
eval "$(argc --argc-eval "$0" "$@")"