Update formatting.

This commit is contained in:
CronyAkatsuki 2023-11-04 22:03:43 +01:00
parent 41754e8ad1
commit e1c508c53b
16 changed files with 287 additions and 278 deletions

View File

@ -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" = "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

View File

@ -4,43 +4,43 @@
editor="$TERMINAL -e $EDITOR" editor="$TERMINAL -e $EDITOR"
declare -a configs=( declare -a configs=(
"Quit" "Quit"
"dk - $HOME/.config/dk/dkrc" "dk - $HOME/.config/dk/dkrc"
"dk sxhkdrc - $HOME/.config/dk/sxhkdrc" "dk sxhkdrc - $HOME/.config/dk/sxhkdrc"
"dk autorun - $HOME/.config/dk/autorun.sh" "dk autorun - $HOME/.config/dk/autorun.sh"
"dunst - $HOME/.config/wal/templates/colors.dunstrc" "dunst - $HOME/.config/wal/templates/colors.dunstrc"
"game-run - $HOME/.config/game-run/config.ini" "game-run - $HOME/.config/game-run/config.ini"
"kitty - $HOME/.config/kitty/kitty.conf" "kitty - $HOME/.config/kitty/kitty.conf"
"lf - $HOME/.config/lf/lfrc" "lf - $HOME/.config/lf/lfrc"
"neovim - $HOME/.config/nvim/init.lua" "neovim - $HOME/.config/nvim/init.lua"
"newsboat config - $HOME/.config/newsboat/config" "newsboat config - $HOME/.config/newsboat/config"
"newsboat urls - $HOME/.config/newsboat/urls" "newsboat urls - $HOME/.config/newsboat/urls"
"picom - $HOME/.config/picom/picom.conf" "picom - $HOME/.config/picom/picom.conf"
"ryzenset - $HOME/.local/share/ryzen-set/profiles.ini" "ryzenset - $HOME/.local/share/ryzen-set/profiles.ini"
"polybar - $HOME/.config/polybar/config.ini" "polybar - $HOME/.config/polybar/config.ini"
"zathura - $HOME/.config/wal/templates/colors.zathurarc" "zathura - $HOME/.config/wal/templates/colors.zathurarc"
"zsh aliases - $HOME/.config/zsh/aliasrc" "zsh aliases - $HOME/.config/zsh/aliasrc"
"zprofile - $HOME/.config/zsh/.zprofile" "zprofile - $HOME/.config/zsh/.zprofile"
"zshenv - $HOME/.zshenv" "zshenv - $HOME/.zshenv"
"zshrc - $HOME/.config/zsh/.zshrc" "zshrc - $HOME/.config/zsh/.zshrc"
"xinitrc - $HOME/.config/X11/xinitrc" "xinitrc - $HOME/.config/X11/xinitrc"
) )
load_config () { load_config() {
source $HOME/.config/dmenu/config source $HOME/.config/dmenu/config
} }
main () { main() {
load_config 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}') cfg=$(printf '%s\n' "${choice}" | awk '{print $NF}')
$editor "$cfg" $editor "$cfg"
} }
main $@ main $@

View File

@ -1,43 +1,42 @@
#!/bin/sh #!/bin/sh
# dmenu script to open up my games # dmenu script to open up my games
load_config () { load_config() {
. $HOME/.config/dmenu/config . $HOME/.config/dmenu/config
} }
get_category () { get_category() {
category=$( game-run list | $DMENU -p "Choose game category:") category=$(game-run list | $DMENU -p "Choose game category:")
[ -z "$category" ] && exit 0 [ -z "$category" ] && exit 0
} }
menu () { menu() {
while [ -z "$game" ] while [ -z "$game" ]; do
do [ -z "$1" ] && game=$(game-run list "$category" | sed '/-18+/d' | $DMENU -p "Choose game to run:")
[ -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 [ -z "$game" ] && get_category
done done
} }
launch_game () { launch_game() {
if game-run launch "$game"; then if game-run launch "$game"; then
quick-notify "Game run" "Launching $game" quick-notify "Game run" "Launching $game"
else else
quick-notify "Game run" "Failed to launch $game" quick-notify "Game run" "Failed to launch $game"
fi fi
} }
main () { main() {
load_config load_config
get_category get_category
menu menu $@
launch_game launch_game
} }
main $@ main $@

View File

@ -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) kf=$(grep keyfile ~/.config/dmenu-keepassxc/config | cut -d: -f 2)
if [ "$2" = copy ]; then 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 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 fi

View File

@ -2,24 +2,24 @@
# kill those pesky proceses # kill those pesky proceses
load_config () { load_config() {
. $HOME/.config/dmenu/config . $HOME/.config/dmenu/config
} }
main () { main() {
load_config 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 $@ main $@

View File

@ -3,27 +3,27 @@
# Feed this script a link or it will get it from your clipboard and it will give dmenu # 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. # with some choice of programs to open the link with.
load_config () { load_config() {
. $HOME/.config/dmenu/config . $HOME/.config/dmenu/config
} }
menu () { menu() {
case "$(printf "mpv\\nmpv audio\\nbrowser\\ncopy url [X11]\\ncopy url [Wayland]\\nw3m" | $DMENU -p "Open link with what program?")" in 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) start-program "$VIDEO" "$@" ;;
"mpv audio") "$VIDEO" "$@" --no-video ;; "mpv audio") "$VIDEO" "$@" --no-video ;;
browser) start-program "$BROWSER" "$@" ;; browser) start-program "$BROWSER" "$@" ;;
"copy url [X11]") echo "$@" | xclip -selection clipboard ;; "copy url [X11]") echo "$@" | xclip -selection clipboard ;;
"copy url [Wayland]") echo "$@" | wl-copy -n ;; "copy url [Wayland]") echo "$@" | wl-copy -n ;;
w3m) readable "$@" | w3m -T text/html ;; w3m) readable "$@" | w3m -T text/html ;;
esac esac
} }
main () { main() {
load_config load_config
[ $# -eq 0 ] && link=$(xclip -sel c -o) || link="$@" [ $# -eq 0 ] && link=$(xclip -sel c -o) || link="$@"
menu $link menu $link
} }
main $@ main $@

View File

@ -3,26 +3,26 @@
# script to run a menu prompt when having more than 2 players since # 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 # playerctl is bad at managing more than one player at the same time
load_config () { load_config() {
. $HOME/.config/dmenu/config . $HOME/.config/dmenu/config
} }
menu () { menu() {
choice=$(playerctl -l | $DMENU -p 'Manage:') choice=$(playerctl -l | $DMENU -p 'Manage:')
[ -z "$choice" ] && exit [ -z "$choice" ] && exit
playerctl -p $choice $1 playerctl -p $choice $1
} }
main () { main() {
load_config load_config
command="$@" command="$@"
[ -z "$command" ] && exit [ -z "$command" ] && exit
instances=$(playerctl -l | wc -l) 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 $@ main $@

View File

@ -2,21 +2,21 @@
# simple power menu script # simple power menu script
load_config () { load_config() {
. $HOME/.config/dmenu/config . $HOME/.config/dmenu/config
} }
menu () { menu() {
case "$(printf "shutdown\\nreboot" | $DMENU -p "Choose your poison")" in case "$(printf "shutdown\\nreboot" | $DMENU -p "Choose your poison")" in
"shutdown") loginctl poweroff ;; "shutdown") loginctl poweroff ;;
"reboot") loginctl reboot ;; "reboot") loginctl reboot ;;
esac esac
} }
main () { main() {
load_config load_config
menu menu
} }
main $@ main $@

View File

@ -1,23 +1,23 @@
#!/bin/sh #!/bin/sh
convert_sizes () { convert_sizes() {
printf '%s\n' "$@" | \ printf '%s\n' "$@" |
while read size; do while read size; do
numfmt --to iec --format "%.2f" $size numfmt --to iec --format "%.2f" $size
done done
} }
list() { list() {
num=1 num=1
printf '%s\n' "$1" | \ printf '%s\n' "$1" |
while read line in; do while read line in; do
category=$(printf '%s' "$2" | sed -n "${num}p") category=$(printf '%s' "$2" | sed -n "${num}p")
seeder=$(printf '%s' "$3" | sed -n "${num}p") seeder=$(printf '%s' "$3" | sed -n "${num}p")
leecher=$(printf '%s' "$4" | sed -n "${num}p") leecher=$(printf '%s' "$4" | sed -n "${num}p")
size=$(printf '%s' "$5" | sed -n "${num}p") size=$(printf '%s' "$5" | sed -n "${num}p")
printf '%s\n' "$num - $line | $category | $seeder | $leecher | $size" printf '%s\n' "$num - $line | $category | $seeder | $leecher | $size"
num=$(($num + 1)) num=$(($num + 1))
done | column -t -s '|' | dmenu -i -l 15 | awk '{print $1}' done | column -t -s '|' | dmenu -i -l 15 | awk '{print $1}'
} }
base_url="https://torrentapi.org/pubapi_v2.php?" 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') 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 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') 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" notify-send "RARGB" "Waiting 5 second for api limit to reset"
sleep 5 sleep 5
done done
default_args="&token=${token}&limit=100&app_id=dmenu-rarbg&format=json_extended" 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') query=$(printf '%s' | dmenu -i -p "Enter search term: " | sed 's/ /%20/g')
if [ "$query" = "" ]; then if [ "$query" = "" ]; then
url="${base_url}mode=list${default_args}" url="${base_url}mode=list${default_args}"
else 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 fi
case "$(printf "All\\nMovies\\nTV Shows\\nGames\\nMusic" | dmenu -i -p "Choose category: ")" in case "$(printf "All\\nMovies\\nTV Shows\\nGames\\nMusic" | dmenu -i -p "Choose category: ")" in
All) url="$url";; All) url="$url" ;;
Movies) url="${url}&category=17;44;45;47;50;51;52;42;46;54";; Movies) url="${url}&category=17;44;45;47;50;51;52;42;46;54" ;;
"TV Shows") url="${url}&category=2;18;41;49";; "TV Shows") url="${url}&category=2;18;41;49" ;;
Games) url="${url}&category=2;27;28;29;30;31;53";; Games) url="${url}&category=2;27;28;29;30;31;53" ;;
Music) url="${url}&category=2;23;24;25;26";; Music) url="${url}&category=2;23;24;25;26" ;;
esac esac
response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}" ) response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}")
while [ "$response" = "" ]; do while [ "$response" = "" ]; do
response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}" ) response=$(curl -sLH "User-agent: 'your bot 0.1'" "${url}")
notify-send "RARGB" "Waiting 5 second for api limit to reset" notify-send "RARGB" "Waiting 5 second for api limit to reset"
sleep 5 sleep 5
done done
[ "$response" = "" ] && notify-send "RARBG" "Wait for 3 seconds for api to work." && exit 1 [ "$response" = "" ] && notify-send "RARBG" "Wait for 3 seconds for api to work." && exit 1

View File

@ -1,15 +1,15 @@
#!/bin/sh #!/bin/sh
load_config () { load_config() {
. $HOME/.config/dmenu/config . $HOME/.config/dmenu/config
} }
main () { main() {
load_config 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 $@ main $@

View File

@ -1,47 +1,46 @@
#!/bin/sh #!/bin/sh
# dmenu script for quickly setting ryzenadj profiles with my other script easily # dmenu script for quickly setting ryzenadj profiles with my other script easily
load_config () { load_config() {
. $HOME/.config/dmenu/config . $HOME/.config/dmenu/config
} }
get_category () { get_category() {
category=$( sudo ryzenset list | $DMENU -i -p "Choose profile category:") category=$(sudo ryzenset list | $DMENU -i -p "Choose profile category:")
[ -z "$category" ] && exit 0 [ -z "$category" ] && exit 0
} }
get_current_profile () { get_current_profile() {
current_mode=$(sudo ryzenset get) current_mode=$(sudo ryzenset get)
} }
menu () { menu() {
while [ -z "$profile" ] while [ -z "$profile" ]; do
do profile=$(sudo ryzenset list $category | $DMENU -i -p "Current: $current_mode:")
profile=$(sudo ryzenset list $category | $DMENU -i -p "Current: $current_mode:")
[ -z "$profile" ] && get_category [ -z "$profile" ] && get_category
done done
} }
launch_profile () { launch_profile() {
if sudo ryzenset set "$profile"; then if sudo ryzenset set "$profile"; then
quick-notify "Ryzenset" "Setting $profile" quick-notify "Ryzenset" "Setting $profile"
else else
quick-notify "Ryzenset" "Failed to set $game" quick-notify "Ryzenset" "Failed to set $game"
fi fi
} }
main () { main() {
load_config load_config
get_category get_category
get_current_profile get_current_profile
menu menu
launch_profile launch_profile
} }
main $@ main $@

View File

@ -2,24 +2,30 @@
# It lets you choose the kind of screenshot to take, including # It lets you choose the kind of screenshot to take, including
# copying the image or even highlighting an area to copy. # copying the image or even highlighting an area to copy.
load_config () { load_config() {
. $HOME/.config/dmenu/config . $HOME/.config/dmenu/config
} }
menu () { menu() {
case "$(printf "a selected area\\nfull screen" | $DMENU -l 6 -p "Screenshot which area?")" in 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" ;; "a selected area")
"full screen") sleep 0.5; maim -m 2 $dir/pic-full-"$(date '+%y%m%d-%H%M-%S').png" ;; sleep 0.5
esac 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 () { main() {
dir="$HOME/pics/screenshots" dir="$HOME/pics/screenshots"
[ ! -d "$dir" ] && mkdir $dir -p [ ! -d "$dir" ] && mkdir $dir -p
load_config load_config
menu menu
} }
main $@ main $@

View File

@ -5,8 +5,8 @@
file=$(fd . "$HOME" --type f --hidden --color=never --exclude ".git" | $DMENU -l 15) file=$(fd . "$HOME" --type f --hidden --color=never --exclude ".git" | $DMENU -l 15)
[ -z "$file" ] && exit [ -z "$file" ] && exit
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then 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 else
curl -F "file=@$file" "https://upfast.cronyakatsuki.xyz" | xclip -selection clipboard curl -F "file=@$file" "https://upfast.cronyakatsuki.xyz" | xclip -selection clipboard
fi fi
notify-send "Dmenu Share" "Ready to share" notify-send "Dmenu Share" "Ready to share"

View File

@ -1,60 +1,65 @@
#!/bin/env bash #!/bin/env bash
load_config () { load_config() {
source $HOME/.config/dmenu/config source $HOME/.config/dmenu/config
} }
move () { move() {
declare -a paths=( declare -a paths=(
"$HOME/vids/anime" "$HOME/vids/anime"
"$HOME/vids/movies" "$HOME/vids/movies"
"$HOME/vids/tv-shows" "$HOME/vids/tv-shows"
"$HOME/docs/manga" "$HOME/docs/manga"
"$HOME/docs/lightnovels" "$HOME/docs/lightnovels"
"$HOME/games/torrents" "$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 if transmission-remote -t $1 --move $choice; then
quick-notify "Transmission" "Moved $1 to $choice" quick-notify "Transmission" "Moved $1 to $choice"
else else
quick-notify "Transmission" "Couldn't move $1 to $choice" quick-notify "Transmission" "Couldn't move $1 to $choice"
fi fi
} }
menu () { menu() {
case "$(printf "Start\\nStop\\nMove\\nRemove" | $DMENU -p "Torrent Action: ")" in case "$(printf "Start\\nStop\\nMove\\nRemove" | $DMENU -i -p "Torrent Action: ")" in
Remove) transmission-remote -t $id -rad Remove)
quick-notify "Transmission" "Removed $id" transmission-remote -t $id -rad
;; quick-notify "Transmission" "Removed $id"
Start) transmission-remote -t $id -s ;;
quick-notify "Transmission" "Started $id" Start)
;; transmission-remote -t $id -s
Stop) transmission-remote -t $id -S quick-notify "Transmission" "Started $id"
quick-notify "Transmission" "Stoped $id" ;;
;; Stop)
Move) move $id transmission-remote -t $id -S
;; quick-notify "Transmission" "Stoped $id"
*) quick-notify "Transmission" "No action chosen" ;;
;; Move)
esac move $id
;;
*)
quick-notify "Transmission" "No action chosen"
;;
esac
} }
main () { main() {
load_config 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 $@ main $@

View File

@ -2,64 +2,64 @@
# a simple dmenu usb managment script # a simple dmenu usb managment script
load_config () { load_config() {
. $HOME/.config/dmenu/config . $HOME/.config/dmenu/config
} }
driveCount(){ driveCount() {
count="$(printf '%s\n' "$1" | wc -l)" count="$(printf '%s\n' "$1" | wc -l)"
} }
mount(){ mount() {
mountable="$(lsblk -lp | awk '/^\/dev\/sd.*part $/ { print $1 " ("$4")" }')" mountable="$(lsblk -lp | awk '/^\/dev\/sd.*part $/ { print $1 " ("$4")" }')"
if [ "$mountable" = "" ]; then if [ "$mountable" = "" ]; then
quick-notify "$DMENU Usb Manager" "No drives to mount" quick-notify "$DMENU Usb Manager" "No drives to mount"
exit exit
fi fi
chosen="$(printf '%s' "$mountable" | $DMENU -p "Drive to mount?")" chosen="$(printf '%s' "$mountable" | $DMENU -p "Drive to mount?")"
if [ -n "$chosen" ];then if [ -n "$chosen" ]; then
udisksctl mount -b "${chosen%% *}" udisksctl mount -b "${chosen%% *}"
quick-notify "Dmenu Usb Manager" "Drive ${chosen%% *} mounted" quick-notify "Dmenu Usb Manager" "Drive ${chosen%% *} mounted"
else else
quick-notify "Dmenu Usb Manager" "No drives chosen to mount" quick-notify "Dmenu Usb Manager" "No drives chosen to mount"
exit exit
fi fi
} }
unmount(){ unmount() {
mounted="$(lsblk -lp | awk '/run/ { print $1 " ("$4")" }')" mounted="$(lsblk -lp | awk '/run/ { print $1 " ("$4")" }')"
if [ "$mounted" = "" ]; then
quick-notify "Dmenu Usb Manager" "No drives to unmount"
exit
fi
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 chosen="$(printf "$mounted" | $DMENU -p "Drive to unmount?")"
udisksctl unmount -b "${chosen%% *}"
quick-notify "Dmenu Usb Manager" "Drive ${chosen%% *} unmounted" if [ -n "$chosen" ]; then
else udisksctl unmount -b "${chosen%% *}"
quick-notify "Dmenu Usb Manager" "No drives chosen to unmount" quick-notify "Dmenu Usb Manager" "Drive ${chosen%% *} unmounted"
exit else
fi quick-notify "Dmenu Usb Manager" "No drives chosen to unmount"
exit
fi
} }
menu () { menu() {
case $(printf "mount\\nunmount" | $DMENU -p "Chose your usb action") in case $(printf "mount\\nunmount" | $DMENU -p "Chose your usb action") in
"mount") mount ;; "mount") mount ;;
"unmount") unmount ;; "unmount") unmount ;;
esac esac
} }
main () { main() {
load_config load_config
menu menu
} }
main $@ main $@

View File

@ -8,33 +8,33 @@ wifi_list=$(nmcli --fields "SECURITY,SSID" device wifi list --rescan yes | sed 1
connected=$(nmcli -fields WIFI g) connected=$(nmcli -fields WIFI g)
if [[ "$connected" =~ "enabled" ]]; then if [[ "$connected" =~ "enabled" ]]; then
toggle="睊 Disable Wi-Fi" toggle="睊 Disable Wi-Fi"
elif [[ "$connected" =~ "disabled" ]]; then elif [[ "$connected" =~ "disabled" ]]; then
toggle="直 Enable Wi-Fi" toggle="直 Enable Wi-Fi"
fi fi
# Use dmenu to select wifi network # 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 # Get name of connection
chosen_id=$(printf '%s\n' "${chosen_network:3}" | xargs) chosen_id=$(printf '%s\n' "${chosen_network:3}" | xargs)
if [ "$chosen_network" = "" ]; then if [ "$chosen_network" = "" ]; then
exit exit
elif [ "$chosen_network" = "直 Enable Wi-Fi" ]; then elif [ "$chosen_network" = "直 Enable Wi-Fi" ]; then
nmcli radio wifi on nmcli radio wifi on
elif [ "$chosen_network" = "睊 Disable Wi-Fi" ]; then elif [ "$chosen_network" = "睊 Disable Wi-Fi" ]; then
nmcli radio wifi off nmcli radio wifi off
else else
# Message to show when connection is activated successfully # Message to show when connection is activated successfully
success_message="You are now connected to the Wi-Fi network \"$chosen_id\"." success_message="You are now connected to the Wi-Fi network \"$chosen_id\"."
# Get saved connections # Get saved connections
saved_connections=$(nmcli -g NAME connection) saved_connections=$(nmcli -g NAME connection)
if [[ $(printf '%s\n' "$saved_connections" | grep -w "$chosen_id") = "$chosen_id" ]]; then 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" nmcli connection up id "$chosen_id" | grep "successfully" && quick-notify "Connection Established" "$success_message"
else else
if [[ "$chosen_network" =~ "" ]]; then if [[ "$chosen_network" =~ "" ]]; then
wifi_password=$($DMENU -P -p "Password: " ) wifi_password=$($DMENU -P -p "Password: ")
fi fi
nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && quick-notify "Connection Established" "$success_message" nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && quick-notify "Connection Established" "$success_message"
fi fi
fi fi