diff --git a/dmenu-buku b/dmenu-buku index 338855a..f524475 100755 --- a/dmenu-buku +++ b/dmenu-buku @@ -6,6 +6,6 @@ [ "$1" = "open" ] && buku --nostdin -p -f5 | sed 's/\t/;/g' | column -t -s ';' | $DMENU -p "Open bookmark: " -i -l 10 | cut -d' ' -f1 | xargs -r buku --nostdin -o -[ "$1" = "edit" ] && buku --nostdin -p -f5 | sed 's/\t/;/g' | column -t -s ';' | $DMENU -p "Edit bookmark: " -i -l 10 | cut -d' ' -f1 | xargs -r $TERMINAL -e buku -w +[ "$1" = "edit" ] && buku --nostdin -p -f5 | sed 's/\t/;/g' | column -t -s ';' | $DMENU -p "Edit bookmark: " -i -l 10 | cut -d' ' -f1 | xargs -r "$TERMINAL" -e buku -w -[ "$1" = "delete" ] && buku --nostdin -p -f5 | sed 's/\t/;/g' | column -t -s ';' | $DMENU -p "Edit bookmark: " -i -l 10 | cut -d' ' -f1 | xargs -r -I % buku --nostdin -d % --tacit && notify-send "Deleted bookmark" +[ "$1" = "delete" ] && buku --nostdin -p -f5 | sed 's/\t/;/g' | column -t -s ';' | $DMENU -p "Delete bookmark: " -i -l 10 | cut -d' ' -f1 | xargs -r -I % buku --nostdin -d % --tacit diff --git a/dmenu-configs b/dmenu-configs index b19a1aa..0eaf318 100755 --- a/dmenu-configs +++ b/dmenu-configs @@ -4,43 +4,43 @@ editor="$TERMINAL -e $EDITOR" declare -a configs=( - "Quit" - "dk - $HOME/.config/dk/dkrc" - "dk sxhkdrc - $HOME/.config/dk/sxhkdrc" - "dk autorun - $HOME/.config/dk/autorun.sh" - "dunst - $HOME/.config/wal/templates/colors.dunstrc" - "game-run - $HOME/.config/game-run/config.ini" - "kitty - $HOME/.config/kitty/kitty.conf" - "lf - $HOME/.config/lf/lfrc" - "neovim - $HOME/.config/nvim/init.lua" - "newsboat config - $HOME/.config/newsboat/config" - "newsboat urls - $HOME/.config/newsboat/urls" - "picom - $HOME/.config/picom/picom.conf" - "ryzenset - $HOME/.local/share/ryzen-set/profiles.ini" - "polybar - $HOME/.config/polybar/config.ini" - "zathura - $HOME/.config/wal/templates/colors.zathurarc" - "zsh aliases - $HOME/.config/zsh/aliasrc" - "zprofile - $HOME/.config/zsh/.zprofile" - "zshenv - $HOME/.zshenv" - "zshrc - $HOME/.config/zsh/.zshrc" - "xinitrc - $HOME/.config/X11/xinitrc" + "Quit" + "dk - $HOME/.config/dk/dkrc" + "dk sxhkdrc - $HOME/.config/dk/sxhkdrc" + "dk autorun - $HOME/.config/dk/autorun.sh" + "dunst - $HOME/.config/wal/templates/colors.dunstrc" + "game-run - $HOME/.config/game-run/config.ini" + "kitty - $HOME/.config/kitty/kitty.conf" + "lf - $HOME/.config/lf/lfrc" + "neovim - $HOME/.config/nvim/init.lua" + "newsboat config - $HOME/.config/newsboat/config" + "newsboat urls - $HOME/.config/newsboat/urls" + "picom - $HOME/.config/picom/picom.conf" + "ryzenset - $HOME/.local/share/ryzen-set/profiles.ini" + "polybar - $HOME/.config/polybar/config.ini" + "zathura - $HOME/.config/wal/templates/colors.zathurarc" + "zsh aliases - $HOME/.config/zsh/aliasrc" + "zprofile - $HOME/.config/zsh/.zprofile" + "zshenv - $HOME/.zshenv" + "zshrc - $HOME/.config/zsh/.zshrc" + "xinitrc - $HOME/.config/X11/xinitrc" ) -load_config () { - source $HOME/.config/dmenu/config +load_config() { + source $HOME/.config/dmenu/config } -main () { - load_config +main() { + load_config - choice=$(printf '%s\n' "${configs[@]}" | $DMENU -l 10 -p 'Edit config:') + choice=$(printf '%s\n' "${configs[@]}" | $DMENU -l 10 -p 'Edit config:') - [ -z "$choice" ] && exit + [ -z "$choice" ] && exit - [ "$choice" = "Quit" ] && exit + [ "$choice" = "Quit" ] && exit - cfg=$(printf '%s\n' "${choice}" | awk '{print $NF}') - $editor "$cfg" + cfg=$(printf '%s\n' "${choice}" | awk '{print $NF}') + $editor "$cfg" } main $@ diff --git a/dmenu-games b/dmenu-games index 0278589..484822f 100755 --- a/dmenu-games +++ b/dmenu-games @@ -1,43 +1,42 @@ #!/bin/sh # dmenu script to open up my games -load_config () { - . $HOME/.config/dmenu/config +load_config() { + . $HOME/.config/dmenu/config } -get_category () { - category=$( game-run list | $DMENU -p "Choose game category:") +get_category() { + category=$(game-run list | $DMENU -p "Choose game category:") - [ -z "$category" ] && exit 0 + [ -z "$category" ] && exit 0 } -menu () { - while [ -z "$game" ] - do - [ -z "$1" ] && game=$(game-run list "$category" | sed '/-18+/d' | $DMENU -p "Choose game to run:") +menu() { + while [ -z "$game" ]; do + [ -z "$1" ] && game=$(game-run list "$category" | sed '/-18+/d' | $DMENU -p "Choose game to run:") - [ "$1" = "-a" ] && game=$(game-run list "$category" | $DMENU -p "Choose game to run:") + [ "$1" = "-a" ] && game=$(game-run list "$category" | $DMENU -p "Choose game to run:") - [ -z "$game" ] && get_category - done + [ -z "$game" ] && get_category + done } -launch_game () { - if game-run launch "$game"; then - quick-notify "Game run" "Launching $game" - else - quick-notify "Game run" "Failed to launch $game" - fi +launch_game() { + if game-run launch "$game"; then + quick-notify "Game run" "Launching $game" + else + quick-notify "Game run" "Failed to launch $game" + fi } -main () { - load_config +main() { + load_config - get_category + get_category - menu + menu $@ - launch_game + launch_game } main $@ diff --git a/dmenu-keepassxc b/dmenu-keepassxc index 39b4913..aab4068 100755 --- a/dmenu-keepassxc +++ b/dmenu-keepassxc @@ -9,7 +9,7 @@ db=$(grep database ~/.config/dmenu-keepassxc/config | cut -d: -f 2) kf=$(grep keyfile ~/.config/dmenu-keepassxc/config | cut -d: -f 2) if [ "$2" = copy ]; then - $DMENU -P -p "Enter KeePassXC database password" | keepassxc-cli show -sa password -k $kf $db "$1" | xclip -sel c + $DMENU -P -p "Enter KeePassXC database password" | keepassxc-cli show -sa password -k $kf $db "$1" | xclip -sel c && quick-notify "Dmenu-KeePassXC" "Password Copied" else - $DMENU -P -p "Enter KeePassXC database password" | keepassxc-cli show -sa password -k $kf $db "$1" + $DMENU -P -p "Enter KeePassXC database password" | keepassxc-cli show -sa password -k $kf $db "$1" fi diff --git a/dmenu-kill b/dmenu-kill index bb1d896..1da3d53 100755 --- a/dmenu-kill +++ b/dmenu-kill @@ -2,24 +2,24 @@ # kill those pesky proceses -load_config () { - . $HOME/.config/dmenu/config +load_config() { + . $HOME/.config/dmenu/config } -main () { - load_config +main() { + load_config - pid=$(ps -e -o pid,%mem,%cpu,comm,cmd | sort -b -k3 -r | $DMENU -l 15 -i -p "Choose procces to kill: " | awk '{print $1}') + pid=$(ps -e -o pid,%mem,%cpu,comm,cmd | sort -b -k3 -r | $DMENU -l 15 -i -p "Choose procces to kill: " | awk '{print $1}') - [ -n "$pid" ] || exit + [ -n "$pid" ] || exit - answer=$(printf "yes\\nno" | $DMENU -p "Are you sure?") + answer=$(printf "yes\\nno" | $DMENU -p "Are you sure?") - [ $answer = "yes" ] || exit + [ $answer = "yes" ] || exit - kill -15 $pid 2>/dev/null + kill -15 $pid 2>/dev/null - quick-notify "Killed Procces" "$pid" + quick-notify "Killed Procces" "$pid" } main $@ diff --git a/dmenu-link-handler b/dmenu-link-handler index 518ee79..9e59fa4 100755 --- a/dmenu-link-handler +++ b/dmenu-link-handler @@ -3,27 +3,27 @@ # Feed this script a link or it will get it from your clipboard and it will give dmenu # with some choice of programs to open the link with. -load_config () { - . $HOME/.config/dmenu/config +load_config() { + . $HOME/.config/dmenu/config } -menu () { - case "$(printf "mpv\\nmpv audio\\nbrowser\\ncopy url [X11]\\ncopy url [Wayland]\\nw3m" | $DMENU -p "Open link with what program?")" in - mpv) start-program "$VIDEO" "$@" ;; - "mpv audio") "$VIDEO" "$@" --no-video ;; - browser) start-program "$BROWSER" "$@" ;; - "copy url [X11]") echo "$@" | xclip -selection clipboard ;; - "copy url [Wayland]") echo "$@" | wl-copy -n ;; - w3m) readable "$@" | w3m -T text/html ;; - esac +menu() { + case "$(printf "mpv\\nmpv audio\\nbrowser\\ncopy url [X11]\\ncopy url [Wayland]\\nw3m" | $DMENU -p "Open link with what program?")" in + mpv) start-program "$VIDEO" "$@" ;; + "mpv audio") "$VIDEO" "$@" --no-video ;; + browser) start-program "$BROWSER" "$@" ;; + "copy url [X11]") echo "$@" | xclip -selection clipboard ;; + "copy url [Wayland]") echo "$@" | wl-copy -n ;; + w3m) readable "$@" | w3m -T text/html ;; + esac } -main () { - load_config +main() { + load_config - [ $# -eq 0 ] && link=$(xclip -sel c -o) || link="$@" + [ $# -eq 0 ] && link=$(xclip -sel c -o) || link="$@" - menu $link + menu $link } main $@ diff --git a/dmenu-playerctl b/dmenu-playerctl index 2680b3c..0be0d0e 100755 --- a/dmenu-playerctl +++ b/dmenu-playerctl @@ -3,26 +3,26 @@ # script to run a menu prompt when having more than 2 players since # playerctl is bad at managing more than one player at the same time -load_config () { - . $HOME/.config/dmenu/config +load_config() { + . $HOME/.config/dmenu/config } -menu () { - choice=$(playerctl -l | $DMENU -p 'Manage:') - [ -z "$choice" ] && exit - playerctl -p $choice $1 +menu() { + choice=$(playerctl -l | $DMENU -p 'Manage:') + [ -z "$choice" ] && exit + playerctl -p $choice $1 } -main () { - load_config +main() { + load_config - command="$@" - [ -z "$command" ] && exit - instances=$(playerctl -l | wc -l) + command="$@" + [ -z "$command" ] && exit + instances=$(playerctl -l | wc -l) - [ "$instances" = "0" ] && exit + [ "$instances" = "0" ] && exit - [ "$instances" -lt "2" ] && playerctl $command || menu $command + [ "$instances" -lt "2" ] && playerctl $command || menu $command } main $@ diff --git a/dmenu-power-menu b/dmenu-power-menu index 877c8d1..4202915 100755 --- a/dmenu-power-menu +++ b/dmenu-power-menu @@ -2,21 +2,21 @@ # simple power menu script -load_config () { - . $HOME/.config/dmenu/config +load_config() { + . $HOME/.config/dmenu/config } -menu () { - case "$(printf "shutdown\\nreboot" | $DMENU -p "Choose your poison")" in - "shutdown") loginctl poweroff ;; - "reboot") loginctl reboot ;; - esac +menu() { + case "$(printf "shutdown\\nreboot" | $DMENU -p "Choose your poison")" in + "shutdown") loginctl poweroff ;; + "reboot") loginctl reboot ;; + esac } -main () { - load_config +main() { + load_config - menu + menu } main $@ diff --git a/dmenu-rarbg b/dmenu-rarbg index dabf9e5..9c9aa05 100755 --- a/dmenu-rarbg +++ b/dmenu-rarbg @@ -1,23 +1,23 @@ #!/bin/sh -convert_sizes () { - printf '%s\n' "$@" | \ - while read size; do - numfmt --to iec --format "%.2f" $size - done +convert_sizes() { + printf '%s\n' "$@" | + while read size; do + numfmt --to iec --format "%.2f" $size + done } list() { - num=1 - printf '%s\n' "$1" | \ - while read line in; do - category=$(printf '%s' "$2" | sed -n "${num}p") - seeder=$(printf '%s' "$3" | sed -n "${num}p") - leecher=$(printf '%s' "$4" | sed -n "${num}p") - size=$(printf '%s' "$5" | sed -n "${num}p") - printf '%s\n' "$num - $line | $category | $seeder | $leecher | $size" - num=$(($num + 1)) - done | column -t -s '|' | dmenu -i -l 15 | awk '{print $1}' + num=1 + printf '%s\n' "$1" | + while read line in; do + category=$(printf '%s' "$2" | sed -n "${num}p") + seeder=$(printf '%s' "$3" | sed -n "${num}p") + leecher=$(printf '%s' "$4" | sed -n "${num}p") + size=$(printf '%s' "$5" | sed -n "${num}p") + printf '%s\n' "$num - $line | $category | $seeder | $leecher | $size" + num=$(($num + 1)) + done | column -t -s '|' | dmenu -i -l 15 | awk '{print $1}' } base_url="https://torrentapi.org/pubapi_v2.php?" @@ -25,9 +25,9 @@ base_url="https://torrentapi.org/pubapi_v2.php?" token=$(curl -sLH "User-agent: 'your bot 0.1'" "${base_url}get_token=get_token&app_id=dmenu-rarbg" | jq -r '.token') while [ "$token" = "" ]; do - token=$(curl -sLH "User-agent: 'your bot 0.1'" "${base_url}get_token=get_token&app_id=dmenu-rarbg" | jq -r '.token') - notify-send "RARGB" "Waiting 5 second for api limit to reset" - sleep 5 + token=$(curl -sLH "User-agent: 'your bot 0.1'" "${base_url}get_token=get_token&app_id=dmenu-rarbg" | jq -r '.token') + notify-send "RARGB" "Waiting 5 second for api limit to reset" + sleep 5 done default_args="&token=${token}&limit=100&app_id=dmenu-rarbg&format=json_extended" @@ -35,25 +35,25 @@ default_args="&token=${token}&limit=100&app_id=dmenu-rarbg&format=json_extended" query=$(printf '%s' | dmenu -i -p "Enter search term: " | sed 's/ /%20/g') if [ "$query" = "" ]; then - url="${base_url}mode=list${default_args}" + url="${base_url}mode=list${default_args}" else - url="${base_url}mode=search&search_string=${query}$&sort=seeders${default_args}" + url="${base_url}mode=search&search_string=${query}$&sort=seeders${default_args}" fi case "$(printf "All\\nMovies\\nTV Shows\\nGames\\nMusic" | dmenu -i -p "Choose category: ")" in - All) url="$url";; - Movies) url="${url}&category=17;44;45;47;50;51;52;42;46;54";; - "TV Shows") url="${url}&category=2;18;41;49";; - Games) url="${url}&category=2;27;28;29;30;31;53";; - Music) url="${url}&category=2;23;24;25;26";; +All) url="$url" ;; +Movies) url="${url}&category=17;44;45;47;50;51;52;42;46;54" ;; +"TV Shows") url="${url}&category=2;18;41;49" ;; +Games) url="${url}&category=2;27;28;29;30;31;53" ;; +Music) url="${url}&category=2;23;24;25;26" ;; esac -response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}" ) +response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}") while [ "$response" = "" ]; do - response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}" ) - notify-send "RARGB" "Waiting 5 second for api limit to reset" - sleep 5 + response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}") + notify-send "RARGB" "Waiting 5 second for api limit to reset" + sleep 5 done [ "$response" = "" ] && notify-send "RARBG" "Wait for 3 seconds for api to work." && exit 1 diff --git a/dmenu-runner b/dmenu-runner index 514766f..eced2b8 100755 --- a/dmenu-runner +++ b/dmenu-runner @@ -1,15 +1,15 @@ #!/bin/sh -load_config () { - . $HOME/.config/dmenu/config +load_config() { + . $HOME/.config/dmenu/config } -main () { - load_config +main() { + load_config - choice=$(dmenu_path | grep dmenu- | $DMENU -p "Choose script to run:") + choice=$(dmenu_path | grep dmenu- | $DMENU -p "Choose script to run:") - $choice + $choice } main $@ diff --git a/dmenu-ryzenadj b/dmenu-ryzenadj index 43a00f9..5c5e375 100755 --- a/dmenu-ryzenadj +++ b/dmenu-ryzenadj @@ -1,47 +1,46 @@ #!/bin/sh # dmenu script for quickly setting ryzenadj profiles with my other script easily -load_config () { - . $HOME/.config/dmenu/config +load_config() { + . $HOME/.config/dmenu/config } -get_category () { - category=$( sudo ryzenset list | $DMENU -i -p "Choose profile category:") +get_category() { + category=$(sudo ryzenset list | $DMENU -i -p "Choose profile category:") - [ -z "$category" ] && exit 0 + [ -z "$category" ] && exit 0 } -get_current_profile () { - current_mode=$(sudo ryzenset get) +get_current_profile() { + current_mode=$(sudo ryzenset get) } -menu () { - while [ -z "$profile" ] - do - profile=$(sudo ryzenset list $category | $DMENU -i -p "Current: $current_mode:") +menu() { + while [ -z "$profile" ]; do + profile=$(sudo ryzenset list $category | $DMENU -i -p "Current: $current_mode:") - [ -z "$profile" ] && get_category - done + [ -z "$profile" ] && get_category + done } -launch_profile () { - if sudo ryzenset set "$profile"; then - quick-notify "Ryzenset" "Setting $profile" - else - quick-notify "Ryzenset" "Failed to set $game" - fi +launch_profile() { + if sudo ryzenset set "$profile"; then + quick-notify "Ryzenset" "Setting $profile" + else + quick-notify "Ryzenset" "Failed to set $game" + fi } -main () { - load_config +main() { + load_config - get_category + get_category - get_current_profile + get_current_profile - menu + menu - launch_profile + launch_profile } main $@ diff --git a/dmenu-screenshot b/dmenu-screenshot index a1f557a..3241f0d 100755 --- a/dmenu-screenshot +++ b/dmenu-screenshot @@ -2,24 +2,30 @@ # It lets you choose the kind of screenshot to take, including # copying the image or even highlighting an area to copy. -load_config () { - . $HOME/.config/dmenu/config +load_config() { + . $HOME/.config/dmenu/config } -menu () { - case "$(printf "a selected area\\nfull screen" | $DMENU -l 6 -p "Screenshot which area?")" in - "a selected area") sleep 0.5; maim -m 2 -s $dir/pic-selected-"$(date '+%y%m%d-%H%M-%S').png" ;; - "full screen") sleep 0.5; maim -m 2 $dir/pic-full-"$(date '+%y%m%d-%H%M-%S').png" ;; - esac +menu() { + case "$(printf "a selected area\\nfull screen" | $DMENU -l 6 -p "Screenshot which area?")" in + "a selected area") + sleep 0.5 + maim -m 2 -s $dir/pic-selected-"$(date '+%y%m%d-%H%M-%S').png" + ;; + "full screen") + sleep 0.5 + maim -m 2 $dir/pic-full-"$(date '+%y%m%d-%H%M-%S').png" + ;; + esac } -main () { - dir="$HOME/pics/screenshots" - [ ! -d "$dir" ] && mkdir $dir -p +main() { + dir="$HOME/pics/screenshots" + [ ! -d "$dir" ] && mkdir $dir -p - load_config + load_config - menu + menu } main $@ diff --git a/dmenu-share b/dmenu-share index 4b7fa52..c3a77b0 100755 --- a/dmenu-share +++ b/dmenu-share @@ -5,8 +5,8 @@ file=$(fd . "$HOME" --type f --hidden --color=never --exclude ".git" | $DMENU -l 15) [ -z "$file" ] && exit if [ "$XDG_SESSION_TYPE" = "wayland" ]; then - curl -F "file=@$file" "https://upfast.cronyakatsuki.xyz" | wl-copy -n + curl -F "file=@$file" "https://upfast.cronyakatsuki.xyz" | wl-copy -n else - curl -F "file=@$file" "https://upfast.cronyakatsuki.xyz" | xclip -selection clipboard + curl -F "file=@$file" "https://upfast.cronyakatsuki.xyz" | xclip -selection clipboard fi notify-send "Dmenu Share" "Ready to share" diff --git a/dmenu-transmission b/dmenu-transmission index c240181..ddf852a 100755 --- a/dmenu-transmission +++ b/dmenu-transmission @@ -1,60 +1,65 @@ #!/bin/env bash -load_config () { - source $HOME/.config/dmenu/config +load_config() { + source $HOME/.config/dmenu/config } -move () { - declare -a paths=( - "$HOME/vids/anime" - "$HOME/vids/movies" - "$HOME/vids/tv-shows" - "$HOME/docs/manga" - "$HOME/docs/lightnovels" - "$HOME/games/torrents" - ) +move() { + declare -a paths=( + "$HOME/vids/anime" + "$HOME/vids/movies" + "$HOME/vids/tv-shows" + "$HOME/docs/manga" + "$HOME/docs/lightnovels" + "$HOME/games/torrents" + ) - current=$(transmission-remote -t $1 -i | grep -i location | awk '{print $2}') + current=$(transmission-remote -t $1 -i | grep -i location | awk '{print $2}') - choice=$(printf '%s\n' "${paths[@]}" | $DMENU -p "Current: $current") + choice=$(printf '%s\n' "${paths[@]}" | $DMENU -i -p "Current: $current") - [ -z "$choice" ] && quick-notify "Transmission" "No path chosen" && exit + [ -z "$choice" ] && quick-notify "Transmission" "No path chosen" && exit - [ ! -d "$choice" ] && mkdir -p "$choice" + [ ! -d "$choice" ] && mkdir -p "$choice" - if transmission-remote -t $1 --move $choice ; then - quick-notify "Transmission" "Moved $1 to $choice" - else - quick-notify "Transmission" "Couldn't move $1 to $choice" - fi + if transmission-remote -t $1 --move $choice; then + quick-notify "Transmission" "Moved $1 to $choice" + else + quick-notify "Transmission" "Couldn't move $1 to $choice" + fi } -menu () { - case "$(printf "Start\\nStop\\nMove\\nRemove" | $DMENU -p "Torrent Action: ")" in - Remove) transmission-remote -t $id -rad - quick-notify "Transmission" "Removed $id" - ;; - Start) transmission-remote -t $id -s - quick-notify "Transmission" "Started $id" - ;; - Stop) transmission-remote -t $id -S - quick-notify "Transmission" "Stoped $id" - ;; - Move) move $id - ;; - *) quick-notify "Transmission" "No action chosen" - ;; - esac +menu() { + case "$(printf "Start\\nStop\\nMove\\nRemove" | $DMENU -i -p "Torrent Action: ")" in + Remove) + transmission-remote -t $id -rad + quick-notify "Transmission" "Removed $id" + ;; + Start) + transmission-remote -t $id -s + quick-notify "Transmission" "Started $id" + ;; + Stop) + transmission-remote -t $id -S + quick-notify "Transmission" "Stoped $id" + ;; + Move) + move $id + ;; + *) + quick-notify "Transmission" "No action chosen" + ;; + esac } -main () { - load_config +main() { + load_config - id=$(transmission-remote -l | $DMENU -l 10 | awk '{print $1}'| sed 's/*//') + id=$(transmission-remote -l | $DMENU -i -l 10 | awk '{print $1}' | sed 's/*//') - [ -z "$id" ] && exit 0 + [ -z "$id" ] && exit 0 - menu + menu } main $@ diff --git a/dmenu-usb-man b/dmenu-usb-man index abb8e2d..2cf9fc5 100755 --- a/dmenu-usb-man +++ b/dmenu-usb-man @@ -2,64 +2,64 @@ # a simple dmenu usb managment script -load_config () { - . $HOME/.config/dmenu/config +load_config() { + . $HOME/.config/dmenu/config } -driveCount(){ - count="$(printf '%s\n' "$1" | wc -l)" +driveCount() { + count="$(printf '%s\n' "$1" | wc -l)" } -mount(){ - mountable="$(lsblk -lp | awk '/^\/dev\/sd.*part $/ { print $1 " ("$4")" }')" +mount() { + mountable="$(lsblk -lp | awk '/^\/dev\/sd.*part $/ { print $1 " ("$4")" }')" - if [ "$mountable" = "" ]; then - quick-notify "$DMENU Usb Manager" "No drives to mount" - exit - fi + if [ "$mountable" = "" ]; then + quick-notify "$DMENU Usb Manager" "No drives to mount" + exit + fi - chosen="$(printf '%s' "$mountable" | $DMENU -p "Drive to mount?")" + chosen="$(printf '%s' "$mountable" | $DMENU -p "Drive to mount?")" - if [ -n "$chosen" ];then - udisksctl mount -b "${chosen%% *}" - quick-notify "Dmenu Usb Manager" "Drive ${chosen%% *} mounted" - else - quick-notify "Dmenu Usb Manager" "No drives chosen to mount" - exit - fi + if [ -n "$chosen" ]; then + udisksctl mount -b "${chosen%% *}" + quick-notify "Dmenu Usb Manager" "Drive ${chosen%% *} mounted" + else + quick-notify "Dmenu Usb Manager" "No drives chosen to mount" + exit + fi } -unmount(){ - mounted="$(lsblk -lp | awk '/run/ { print $1 " ("$4")" }')" - - if [ "$mounted" = "" ]; then - quick-notify "Dmenu Usb Manager" "No drives to unmount" - exit - fi +unmount() { + mounted="$(lsblk -lp | awk '/run/ { print $1 " ("$4")" }')" - chosen="$(printf "$mounted" | $DMENU -p "Drive to unmount?")" + if [ "$mounted" = "" ]; then + quick-notify "Dmenu Usb Manager" "No drives to unmount" + exit + fi - if [ -n "$chosen" ];then - udisksctl unmount -b "${chosen%% *}" - quick-notify "Dmenu Usb Manager" "Drive ${chosen%% *} unmounted" - else - quick-notify "Dmenu Usb Manager" "No drives chosen to unmount" - exit - fi + chosen="$(printf "$mounted" | $DMENU -p "Drive to unmount?")" + + if [ -n "$chosen" ]; then + udisksctl unmount -b "${chosen%% *}" + quick-notify "Dmenu Usb Manager" "Drive ${chosen%% *} unmounted" + else + quick-notify "Dmenu Usb Manager" "No drives chosen to unmount" + exit + fi } -menu () { - case $(printf "mount\\nunmount" | $DMENU -p "Chose your usb action") in - "mount") mount ;; - "unmount") unmount ;; - esac +menu() { + case $(printf "mount\\nunmount" | $DMENU -p "Chose your usb action") in + "mount") mount ;; + "unmount") unmount ;; + esac } -main () { - load_config +main() { + load_config - menu + menu } main $@ diff --git a/dmenu-wifi b/dmenu-wifi index 5675cbd..f6a5c27 100755 --- a/dmenu-wifi +++ b/dmenu-wifi @@ -8,33 +8,33 @@ wifi_list=$(nmcli --fields "SECURITY,SSID" device wifi list --rescan yes | sed 1 connected=$(nmcli -fields WIFI g) if [[ "$connected" =~ "enabled" ]]; then - toggle="睊 Disable Wi-Fi" + toggle="睊 Disable Wi-Fi" elif [[ "$connected" =~ "disabled" ]]; then - toggle="直 Enable Wi-Fi" + toggle="直 Enable Wi-Fi" fi # Use dmenu to select wifi network -chosen_network=$(printf '%s\n%s' "$toggle" "$wifi_list" | uniq -u | $DMENU -p "Wi-Fi SSID: " ) +chosen_network=$(printf '%s\n%s' "$toggle" "$wifi_list" | uniq -u | $DMENU -p "Wi-Fi SSID: ") # Get name of connection chosen_id=$(printf '%s\n' "${chosen_network:3}" | xargs) if [ "$chosen_network" = "" ]; then - exit + exit elif [ "$chosen_network" = "直 Enable Wi-Fi" ]; then - nmcli radio wifi on + nmcli radio wifi on elif [ "$chosen_network" = "睊 Disable Wi-Fi" ]; then - nmcli radio wifi off + nmcli radio wifi off else - # Message to show when connection is activated successfully - success_message="You are now connected to the Wi-Fi network \"$chosen_id\"." - # Get saved connections - saved_connections=$(nmcli -g NAME connection) - if [[ $(printf '%s\n' "$saved_connections" | grep -w "$chosen_id") = "$chosen_id" ]]; then - nmcli connection up id "$chosen_id" | grep "successfully" && quick-notify "Connection Established" "$success_message" - else - if [[ "$chosen_network" =~ "" ]]; then - wifi_password=$($DMENU -P -p "Password: " ) - fi - nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && quick-notify "Connection Established" "$success_message" - fi + # Message to show when connection is activated successfully + success_message="You are now connected to the Wi-Fi network \"$chosen_id\"." + # Get saved connections + saved_connections=$(nmcli -g NAME connection) + if [[ $(printf '%s\n' "$saved_connections" | grep -w "$chosen_id") = "$chosen_id" ]]; then + nmcli connection up id "$chosen_id" | grep "successfully" && quick-notify "Connection Established" "$success_message" + else + if [[ "$chosen_network" =~ "" ]]; then + wifi_password=$($DMENU -P -p "Password: ") + fi + nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && quick-notify "Connection Established" "$success_message" + fi fi