From 272fb806ef9554459b61654b4b7dcdcdc540fefd Mon Sep 17 00:00:00 2001 From: cronyakatsuki Date: Tue, 5 Apr 2022 16:59:13 +0200 Subject: [PATCH] Updated my scripts. --- dmenu-dl-manager | 32 +++++++++++++++++ dmenufilehandler => dmenu-file-handler | 9 +++-- dmenugames => dmenu-games | 4 ++- dmenugpu => dmenu-gpu | 8 +++-- dmenukill => dmenu-kill | 2 ++ dmenu-link-handler | 13 +++++++ dmenu-power-menu | 8 +++++ dmenuprograms => dmenu-programs | 12 +++---- dmenu-ryzenadj | 20 +++++++++++ ...rof-manager => dmenu-ryzenadj-prof-manager | 1 - dmenu-screenshot | 16 +++++++++ dmenuusbman => dmenu-usb-man | 2 ++ dmenuwifi => dmenu-wifi | 34 +++++++++---------- dmenulinkhandler | 11 ------ dmenupowermenu | 6 ---- dmenuryzenadj | 18 ---------- dmenuscreenshot | 14 -------- 17 files changed, 128 insertions(+), 82 deletions(-) create mode 100755 dmenu-dl-manager rename dmenufilehandler => dmenu-file-handler (92%) rename dmenugames => dmenu-games (68%) rename dmenugpu => dmenu-gpu (86%) rename dmenukill => dmenu-kill (91%) create mode 100755 dmenu-link-handler create mode 100755 dmenu-power-menu rename dmenuprograms => dmenu-programs (55%) create mode 100755 dmenu-ryzenadj rename dmenuryzenadj-prof-manager => dmenu-ryzenadj-prof-manager (82%) create mode 100755 dmenu-screenshot rename dmenuusbman => dmenu-usb-man (96%) rename dmenuwifi => dmenu-wifi (50%) delete mode 100755 dmenulinkhandler delete mode 100755 dmenupowermenu delete mode 100755 dmenuryzenadj delete mode 100755 dmenuscreenshot diff --git a/dmenu-dl-manager b/dmenu-dl-manager new file mode 100755 index 0000000..8ca45ca --- /dev/null +++ b/dmenu-dl-manager @@ -0,0 +1,32 @@ +#!/bin/sh + +# script to download a file from that has it's link in clipboard + +# a functions that list all everything in a directory and gives back the chosen one +choice (){ + (ls -1 -a | dmenu -l 30 -p "Choose where to download") +} + +# first choice +dir=$(choice) + +# while the coice is not a file do what is inside +while [ "$dir" != "Here" ] +do + # first we check if it is a single dot and if it we download there + [ "$dir" = "." ] && break + + # if dir is empty we exit + [ -z "$dir" ] && exit + + # if all checks are negative we change into the directory + cd "$dir" + + # doing a new check + dir=$(choice) +done + +# download the file +quick-notify "Dmenu downloader" "Started downloading a file" +aria2c -j 16 -s 16 -x 16 -k 5M --file-allocation=none "$(xclip -o)" +quick-notify "Dmenu downloader" "Downloading finished" diff --git a/dmenufilehandler b/dmenu-file-handler similarity index 92% rename from dmenufilehandler rename to dmenu-file-handler index 8bc809e..d77afed 100755 --- a/dmenufilehandler +++ b/dmenu-file-handler @@ -8,10 +8,9 @@ # cd into the given directory cd $1 - # a functions that list all everything in a directory and gives back the chosen one choice (){ -(ls -1 -a | dmenu -l 30 -p "Choose your file!") + (ls -1 -a | dmenu -l 30 -p "Choose your file!") } # first choice @@ -25,14 +24,14 @@ do # if dir is empty we exit [ -z "$dir" ] && exit - + # if all check are negative we change into the directory cd "$dir" - + # doing a new check dir=$(choice) done # open the file using xdg-open -quick-notify "Opening file" "$dir" xdg-open "$dir" +quick-notify "Opening file" "$dir" diff --git a/dmenugames b/dmenu-games similarity index 68% rename from dmenugames rename to dmenu-games index d5de6c5..4ff9121 100755 --- a/dmenugames +++ b/dmenu-games @@ -1,11 +1,13 @@ #!/bin/bash +# dmenu script to open up my games or game launcher's + declare -a Games=( "Heroic (Launcher)" "Lutris (Launcher)" ) case "$(printf "%s\n" "${Games[@]}" | dmenu -p "Choose your game")" in - "Heroic (Launcher)") heroic ;; + "Heroic (Launcher)") heroic ;; "Lutris (Launcher)") lutris ;; esac diff --git a/dmenugpu b/dmenu-gpu similarity index 86% rename from dmenugpu rename to dmenu-gpu index 9459d39..313941f 100755 --- a/dmenugpu +++ b/dmenu-gpu @@ -1,5 +1,7 @@ #!/bin/sh +# a simple "gui" for envycontrol + already_in() { quick-notify "Gpu Manager" "Already in $new_mode mode" @@ -15,9 +17,9 @@ switch() } case "$(printf "integrated\\nhybrid\\nnvidia" | dmenu -p "Choose gpu mode")" in - "integrated") new_mode="integrated";; - "nvidia") new_mode="nvidia";; - "hybrid") new_mode="hybrid";; + "integrated") new_mode="integrated";; + "nvidia") new_mode="nvidia";; + "hybrid") new_mode="hybrid";; esac current_mode=$(envycontrol.py --status | awk '{ print $5 }') diff --git a/dmenukill b/dmenu-kill similarity index 91% rename from dmenukill rename to dmenu-kill index ff04a04..7b5e6f8 100755 --- a/dmenukill +++ b/dmenu-kill @@ -1,5 +1,7 @@ #!/bin/sh +# kill those pesky proceses + selected=$(ps --user "$USER" -F | dmenu -p "Select procces to kill:" -l 5 | awk '{print $2" "$11}') [ -n "$selected" ] || exit diff --git a/dmenu-link-handler b/dmenu-link-handler new file mode 100755 index 0000000..fdd3c18 --- /dev/null +++ b/dmenu-link-handler @@ -0,0 +1,13 @@ +#!/bin/sh + +# 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. + +[ -z "$@" ] && link=$(xclip -o) || link="$@" + +case "$(printf "mpv\\nbrowser\\ncopy url\\nw3m" | dmenu -p "Open link with what program?")" in + mpv) "$VIDEO" "$link" ;; + browser) "$BROWSER" "$link" > /dev/null;; + "copy url") echo "$link" | xclip -selection clipboard ;; + w3m) readable "$link" | w3m -T text/html ;; +esac diff --git a/dmenu-power-menu b/dmenu-power-menu new file mode 100755 index 0000000..2279baa --- /dev/null +++ b/dmenu-power-menu @@ -0,0 +1,8 @@ +#!/bin/sh + +# simple power menu script + +case "$(printf "shutdown\\nreboot" | dmenu -p "Choose your poison")" in + "shutdown") systemctl poweroff ;; + "reboot") systemctl reboot ;; +esac diff --git a/dmenuprograms b/dmenu-programs similarity index 55% rename from dmenuprograms rename to dmenu-programs index 91de4ac..88a20d7 100755 --- a/dmenuprograms +++ b/dmenu-programs @@ -1,12 +1,12 @@ #!/bin/bash +# dmenu script to run one of my most runned programs + declare -a software=( -"bitwarden-desktop" -"obs" -"godot" -"megasync" -"spotify" -"discord" + "bitwarden-desktop" + "megasync" + "spotify" + "discord" ) choice=$(printf "%s\n" "${software[@]}" | dmenu -p "Choose software to run") diff --git a/dmenu-ryzenadj b/dmenu-ryzenadj new file mode 100755 index 0000000..6325e1a --- /dev/null +++ b/dmenu-ryzenadj @@ -0,0 +1,20 @@ +#!/bin/sh + +# dmenu script for quickly running specific ryzenadj commands + +current_temp=$(sudo /bin/ryzenadj -i | grep 'tctl-temp' | awk '{ print $6 }') +slow_time=$(sudo /bin/ryzenadj -i | grep 'slow-time' | awk '{ print $4 }') + +[ "$current_temp" = "60.000" ] && current_mode="normal mode" +[ "$current_temp" = "65.000" ] && current_mode="light gaming" +[ "$current_temp" = "70.000" ] && current_mode="heavy gaming" +[ "$current_temp" = "75.000" ] && current_mode="heavy programs" +[ "$current_temp" = "85.000" ] && current_mode="heavy gaming pro" + +case "$(printf "normal mode\\nlight gaming\\nheavy gaming\\nheavy programs\\nheavy gaming pro" | dmenu -p "Current: $current_mode")" in + "normal mode") sudo ryzenadj --slow-time=30 --vrmmax-current=30000 --tctl-temp=60 --stapm-limit=10000 --stapm-time=300 --fast-limit=12000 --slow-limit=11000 --power-saving; break ;; + "light gaming") sudo ryzenadj --slow-time=30 --vrmmax-current=35000 --tctl-temp=65 --stapm-limit=10000 --stapm-time=300 --fast-limit=12000 --slow-limit=11000 --max-performance; break ;; + "heavy gaming") sudo ryzenadj --slow-time=60 --vrmmax-current=60000 --tctl-temp=70 --stapm-limit=20000 --stapm-time=1000 --fast-limit=25000 --slow-limit=21000 --max-performance; break ;; + "heavy programs") sudo ryzenadj --slow-time=60 --vrmmax-current=60000 --tctl-temp=75 --stapm-limit=25000 --stapm-time=1000 --fast-limit=30000 --slow-limit=27000 --max-performance; break ;; + "heavy gaming pro") sudo ryzenadj --slow-time=60 --vrmmax-current=70000 --tctl-temp=85 --stapm-limit=35000 --stapm-time=1000 --fast-limit=50000 --slow-limit=48000 --max-performance; break ;; +esac diff --git a/dmenuryzenadj-prof-manager b/dmenu-ryzenadj-prof-manager similarity index 82% rename from dmenuryzenadj-prof-manager rename to dmenu-ryzenadj-prof-manager index e870c3a..bc3ef46 100755 --- a/dmenuryzenadj-prof-manager +++ b/dmenu-ryzenadj-prof-manager @@ -10,5 +10,4 @@ profile=$(ls -1 -A | dmenu -l 30 -p "Choose your file!") [ -n "$profile" ] || exit -quick-notify "Loading profile" "$profile" ./$profile diff --git a/dmenu-screenshot b/dmenu-screenshot new file mode 100755 index 0000000..0d2464a --- /dev/null +++ b/dmenu-screenshot @@ -0,0 +1,16 @@ +#!/bin/sh + +# It lets you choose the kind of screenshot to take, including +# copying the image or even highlighting an area to copy. + +dir="$HOME/Pictures/screenshots" +[ ! -d "$dir" ] && mkdir $dir -p + +case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -p "Screenshot which area?")" in + "a selected area") sleep 0.5; maim -s $dir/pic-selected-"$(date '+%y%m%d-%H%M-%S').png" ;; + "current window") sleep 0.5; maim -i "$(xdotool getactivewindow)" $dir/pic-window-"$(date '+%y%m%d-%H%M-%S').png" ;; + "full screen") sleep 0.5; maim $dir/pic-full-"$(date '+%y%m%d-%H%M-%S').png" ;; + "a selected area (copy)") sleep 0.5; maim -s | xclip -selection clipboard -t image/png ;; + "current window (copy)") sleep 0.5; maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;; + "full screen (copy)") sleep 0.5; maim | xclip -selection clipboard -t image/png ;; +esac diff --git a/dmenuusbman b/dmenu-usb-man similarity index 96% rename from dmenuusbman rename to dmenu-usb-man index 7c5597a..70386eb 100755 --- a/dmenuusbman +++ b/dmenu-usb-man @@ -1,5 +1,7 @@ #!/bin/sh +# a simple dmenu usb managment script + driveCount(){ count="$(echo "$1" | wc -l)" } diff --git a/dmenuwifi b/dmenu-wifi similarity index 50% rename from dmenuwifi rename to dmenu-wifi index e2aa503..0524014 100755 --- a/dmenuwifi +++ b/dmenu-wifi @@ -6,9 +6,9 @@ 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 @@ -17,22 +17,22 @@ chosen_network=$(echo -e "$toggle\n$wifi_list" | uniq -u | dmenu -p "Wi-Fi SSID: chosen_id=$(echo "${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 [[ $(echo "$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 "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 [[ $(echo "$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 "Password: " ) + fi + nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && quick-notify "Connection Established" "$success_message" + fi fi diff --git a/dmenulinkhandler b/dmenulinkhandler deleted file mode 100755 index da5e5e3..0000000 --- a/dmenulinkhandler +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# Feed this script a link and it will give dmenu -# with some choice of programs to open the link with. - -case "$(printf "mpv\\nbrowser\\ncopy url\\nw3m" | dmenu -p "Open link with what program?")" in - mpv) "$VIDEO" "$1" ;; - browser) "$BROWSER" "$1" > /dev/null;; - "copy url") echo "$1" | xclip -selection clipboard ;; - w3m) readable "$1" | w3m -T text/html ;; -esac diff --git a/dmenupowermenu b/dmenupowermenu deleted file mode 100755 index 555151a..0000000 --- a/dmenupowermenu +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -case "$(printf "shutdown\\nreboot" | dmenu -p "Choose your poison")" in - "shutdown") systemctl poweroff ;; - "reboot") systemctl reboot ;; -esac diff --git a/dmenuryzenadj b/dmenuryzenadj deleted file mode 100755 index 56cb195..0000000 --- a/dmenuryzenadj +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -current_temp=$(sudo /bin/ryzenadj -i | grep 'tctl-temp' | awk '{ print $6 }') -slow_time=$(sudo /bin/ryzenadj -i | grep 'slow-time' | awk '{ print $4 }') - -[ "$current_temp" = "60.000" ] && current_mode="normal mode" -[ "$current_temp" = "65.000" ] && current_mode="light gaming" -[ "$current_temp" = "70.000" ] && current_mode="heavy gaming" -[ "$current_temp" = "75.000" ] && current_mode="heavy programs" -[ "$current_temp" = "85.000" ] && current_mode="heavy gaming pro" - -case "$(printf "normal mode\\nlight gaming\\nheavy gaming\\nheavy programs\\nheavy gaming pro" | dmenu -p "Current: $current_mode")" in - "normal mode") sudo ryzenadj --slow-time=30 --vrmmax-current=30000 --tctl-temp=60 --stapm-limit=10000 --stapm-time=300 --fast-limit=12000 --slow-limit=11000 --power-saving; break ;; - "light gaming") sudo ryzenadj --slow-time=30 --vrmmax-current=35000 --tctl-temp=65 --stapm-limit=10000 --stapm-time=300 --fast-limit=12000 --slow-limit=11000 --max-performance; break ;; - "heavy gaming") sudo ryzenadj --slow-time=60 --vrmmax-current=60000 --tctl-temp=70 --stapm-limit=20000 --stapm-time=1000 --fast-limit=25000 --slow-limit=21000 --max-performance; break ;; - "heavy programs") sudo ryzenadj --slow-time=60 --vrmmax-current=60000 --tctl-temp=75 --stapm-limit=25000 --stapm-time=1000 --fast-limit=30000 --slow-limit=27000 --max-performance; break ;; - "heavy gaming pro") sudo ryzenadj --slow-time=60 --vrmmax-current=70000 --tctl-temp=85 --stapm-limit=35000 --stapm-time=1000 --fast-limit=50000 --slow-limit=48000 --max-performance; break ;; -esac diff --git a/dmenuscreenshot b/dmenuscreenshot deleted file mode 100755 index 017db73..0000000 --- a/dmenuscreenshot +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# It lets you -# choose the kind of screenshot to take, including copying the image or even -# highlighting an area to copy. scrotcucks on suicidewatch right now. - -case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -p "Screenshot which area?")" in - "a selected area") sleep 0.5; maim -s $HOME/Pictures/screenshots/pic-selected-"$(date '+%y%m%d-%H%M-%S').png" ;; - "current window") sleep 0.5; maim -i "$(xdotool getactivewindow)" $HOME/Pictures/screenshots/pic-window-"$(date '+%y%m%d-%H%M-%S').png" ;; - "full screen") sleep 0.5; maim $HOME/Pictures/screenshots/pic-full-"$(date '+%y%m%d-%H%M-%S').png" ;; - "a selected area (copy)") sleep 0.5; maim -s | xclip -selection clipboard -t image/png ;; - "current window (copy)") sleep 0.5; maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;; - "full screen (copy)") sleep 0.5; maim | xclip -selection clipboard -t image/png ;; -esac