From 228d2387446c8d54e2b4e79fa4159d5b8bd1d99d Mon Sep 17 00:00:00 2001 From: Myned Date: Sat, 23 Nov 2024 21:20:44 -0600 Subject: [PATCH] menu.sh: refactor with argc Signed-off-by: Myned --- options/custom/scripts/default.nix | 1 + options/custom/scripts/menu.sh | 137 ++++++++++++++++++----------- 2 files changed, 86 insertions(+), 52 deletions(-) diff --git a/options/custom/scripts/default.nix b/options/custom/scripts/default.nix index 667a044..719d083 100644 --- a/options/custom/scripts/default.nix +++ b/options/custom/scripts/default.nix @@ -113,6 +113,7 @@ in { sway ]) (bash "menu" [ + argc coreutils hyprland jq diff --git a/options/custom/scripts/menu.sh b/options/custom/scripts/menu.sh index 1f3c226..57b58ae 100644 --- a/options/custom/scripts/menu.sh +++ b/options/custom/scripts/menu.sh @@ -1,60 +1,93 @@ #! /usr/bin/env bash -# Menu wrapper -#?? menu +# @describe Wrapper for menu commands +# +# https://github.com/sigoden/argc -command=walker - -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 +# @meta combine-shorts # HACK: Restart service to close existing menu if hyprctl -j layers | jq -e '.[][][][] | select(.namespace == "walker")'; then systemctl --user restart walker.service -else - $command + exit 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" "$@")"