From 9c46cb4d428847560d56b278fcc903935ea317d0 Mon Sep 17 00:00:00 2001 From: Clay Gomera Date: Sat, 8 Jan 2022 22:53:03 -0400 Subject: [PATCH] updated --- config/awesome/config.org | 6 ++++ config/awesome/rc.lua | 4 +++ shell-scripts/rofi-power-menu.sh | 24 ++++++++++++++ shell-scripts/rofi-scrot-menu.sh | 39 +++++++++++++++++++++++ shell-scripts/rofi-wifi-menu.sh | 54 +++++++++++++++++++------------- 5 files changed, 106 insertions(+), 21 deletions(-) create mode 100755 shell-scripts/rofi-power-menu.sh create mode 100755 shell-scripts/rofi-scrot-menu.sh mode change 100644 => 100755 shell-scripts/rofi-wifi-menu.sh diff --git a/config/awesome/config.org b/config/awesome/config.org index 48c5fe722..80247501e 100644 --- a/config/awesome/config.org +++ b/config/awesome/config.org @@ -343,6 +343,10 @@ globalkeys = my_table.join( {description = "show rofi window menu", group = "hotkeys"}), awful.key({ modkey }, "w", function () awful.util.spawn("/home/drk/.shell-scripts/./rofi-wifi-menu.sh") end, {description = "show rofi wifi menu", group = "hotkeys"}), + awful.key({ modkey, altkey }, "Delete", function () awful.util.spawn("/home/drk/.shell-scripts/./rofi-power-menu.sh") end, + {description = "show rofi power menu", group = "hotkeys"}), + awful.key({ modkey, altkey }, "Print", function () awful.util.spawn("/home/drk/.shell-scripts/./rofi-scrot-menu.sh") end, + {description = "show rofi power menu", group = "hotkeys"}), -- Keyboard Layouts awful.key({ modkey, "Shift" }, "e", function () awful.util.spawn("setxkbmap -layout es") end, @@ -574,6 +578,8 @@ clientbuttons = gears.table.join( root.keys(globalkeys) #+end_src +#+RESULTS: + * Rules Here are the rules, so basically here you can specify how you want Awesomewm to manage clients. I edited this to make sure that my master client always stays in its default position, for example in the master and stack layout or "tile layout", it wont matter how much apps i open, my main client will stay there in the main position. Also you can edit this to specify wich apps needs to open always in floating mode and a bunch of other things. #+begin_src lua diff --git a/config/awesome/rc.lua b/config/awesome/rc.lua index 32b37ac98..d3982ee70 100644 --- a/config/awesome/rc.lua +++ b/config/awesome/rc.lua @@ -258,6 +258,10 @@ globalkeys = my_table.join( {description = "show rofi window menu", group = "hotkeys"}), awful.key({ modkey }, "w", function () awful.util.spawn("/home/drk/.shell-scripts/./rofi-wifi-menu.sh") end, {description = "show rofi wifi menu", group = "hotkeys"}), + awful.key({ modkey, altkey }, "Delete", function () awful.util.spawn("/home/drk/.shell-scripts/./rofi-power-menu.sh") end, + {description = "show rofi power menu", group = "hotkeys"}), + awful.key({ modkey, altkey }, "Print", function () awful.util.spawn("/home/drk/.shell-scripts/./rofi-scrot-menu.sh") end, + {description = "show rofi power menu", group = "hotkeys"}), -- Keyboard Layouts awful.key({ modkey, "Shift" }, "e", function () awful.util.spawn("setxkbmap -layout es") end, diff --git a/shell-scripts/rofi-power-menu.sh b/shell-scripts/rofi-power-menu.sh new file mode 100755 index 000000000..ac4380392 --- /dev/null +++ b/shell-scripts/rofi-power-menu.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +option1=" lock" +option2=" logout" +option3=" reboot" +option4=" power off" +option5=" suspend" + +options="$option1\n$option2\n$option3\n$option4\n$option5" + +choice=$(echo -e "$options" | rofi -dmenu -i -no-show-icons -lines 5 -width 20 -p " ") + +case $choice in + $option1) + betterlockscreen -l ;; + $option2) + killall awesome;; + $option3) + systemctl reboot ;; + $option4) + systemctl poweroff ;; + $option5) + systemctl suspend ;; +esac diff --git a/shell-scripts/rofi-scrot-menu.sh b/shell-scripts/rofi-scrot-menu.sh new file mode 100755 index 000000000..3bebc27ab --- /dev/null +++ b/shell-scripts/rofi-scrot-menu.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# This script requires scrot +mkdir -p $HOME/Pictures/Scrot +option1=" Entire screen" +option2=" Entire screen with delay" +option3=" Focused window" +option4=" Select area" + +options="$option1\n$option2\n$option3\n$option4" + +choice=$(echo -e "$options" | rofi -i -dmenu -no-show-icons -no-sidebar-mode -lines 4 -width 20 -p " ") + +case $choice in + $option1) + scrot -e 'mv $f ~/Pictures/Scrot/' && notify-send -a 'Scrot' 'Screenshot saved.' -i 'dialog-information' -t 2000 ;; + $option2) + delayoption1="Take screenshot with 3 sec delay" + delayoption2="Take screenshot with 5 sec delay" + delayoption3="Take screenshot with 10 sec delay" + delayoptions="$delayoption1\n$delayoption2\n$delayoption3" + delay=$(echo -e "$delayoptions" | rofi -i -dmenu -no-show-icons -no-sidebar-mode -lines 3 -width 20 -p " ") + + case $delay in + + $delayoption1) + scrot -d 3 -e 'mv $f ~/Pictures/Scrot/' && notify-send -a 'Scrot' 'Screenshot saved.' -i 'dialog-information' -t 2000 ;; + $delayoption2) + scrot -d 5 -e 'mv $f ~/Pictures/Scrot/' && notify-send -a 'Scrot' 'Screenshot saved.' -i 'dialog-information' -t 2000 ;; + $delayoption3) + scrot -d 10 -e 'mv $f ~/Pictures/Scrot/' && notify-send -a 'Scrot' 'Screenshot saved.' -i 'dialog-information' -t 2000 ;; + esac ;; + + $option3) + scrot -u -b -e 'mv $f ~/Pictures/Scrot/' && notify-send -a 'Scrot' 'Screenshot saved.' -i 'dialog-information' -t 2000 ;; + $option4) + scrot -s -e 'mv $f ~/Pictures/Scrot/' && notify-send -a 'Scrot' 'Screenshot saved.' -i 'dialog-information' -t 2000 ;; + +esac diff --git a/shell-scripts/rofi-wifi-menu.sh b/shell-scripts/rofi-wifi-menu.sh old mode 100644 new mode 100755 index 22b2a48ca..99f8a3be2 --- a/shell-scripts/rofi-wifi-menu.sh +++ b/shell-scripts/rofi-wifi-menu.sh @@ -1,38 +1,50 @@ #!/usr/bin/env bash notify-send "Getting list of available Wi-Fi networks..." +nmcli -t d wifi rescan # Get a list of available wifi connections and morph it into a nice-looking list -wifi_list=$(nmcli --fields "SECURITY,SSID" device wifi list | sed 1d | sed 's/ */ /g' | sed -E "s/WPA*.?\S/ /g" | sed "s/^--/ /g" | sed "s/ //g" | sed "/--/d") +LIST=$(nmcli --fields SSID,SECURITY,BARS device wifi list | sed '/^--/d' | sed 1d | sed -E "s/WPA*.?\S/~~/g" | sed "s/~~ ~~/~~/g;s/802\.1X//g;s/--/~~/g;s/ *~/~/g;s/~ */~/g;s/_/ /g" | column -t -s '~') -connected=$(nmcli -fields WIFI g) -if [[ "$connected" =~ "enabled" ]]; then - toggle="睊 Disable Wi-Fi" -elif [[ "$connected" =~ "disabled" ]]; then - toggle="直 Enable Wi-Fi" +# get current connection status +CONSTATE=$(nmcli -fields WIFI g) +if [[ "$CONSTATE" =~ "enabled" ]]; then + TOGGLE="Disable WiFi 睊" +elif [[ "$CONSTATE" =~ "disabled" ]]; then + TOGGLE="Enable WiFi 直" fi # Use rofi to select wifi network -chosen_network=$(echo -e "$toggle\n$wifi_list" | uniq -u | rofi -dmenu -i -selected-row 1 -p "Wi-Fi SSID: " ) +CHENTRY=$(echo -e "$TOGGLE\n$LIST" | uniq -u | rofi -dmenu -selected-row 1 -p "Wi-Fi SSID: ") # Get name of connection -chosen_id=$(echo "${chosen_network:3}" | xargs) +CHSSID=$(echo "$CHENTRY" | sed 's/\s\{2,\}/\|/g' | awk -F "|" '{print $1}') -if [ "$chosen_network" = "" ]; then - exit -elif [ "$chosen_network" = "直 Enable Wi-Fi" ]; then +if [ "$CHENTRY" = "" ]; then + exit +elif [ "$CHENTRY" = "Enable WiFi 直" ]; then nmcli radio wifi on -elif [ "$chosen_network" = "睊 Disable Wi-Fi" ]; then +elif [ "$CHENTRY" = "Disable WiFi 睊" ]; then 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" && notify-send "Connection Established" "$success_message" + # get list of known connections + KNOWNCON=$(nmcli connection show) + + # If the connection is already in use, then this will still be able to get the SSID + if [ "$CHSSID" = "*" ]; then + CHSSID=$(echo "$CHENTRY" | sed 's/\s\{2,\}/\|/g' | awk -F "|" '{print $3}') + fi + + # Parses the list of preconfigured connections to see if it already contains the chosen SSID. This speeds up the connection process + if [[ $(echo "$KNOWNCON" | grep "$CHSSID") = "$CHSSID" ]]; then + nmcli con up "$CHSSID" else - if [[ "$chosen_network" =~ "" ]]; then - wifi_password=$(rofi -dmenu -p "Password: " ) + if [[ "$CHENTRY" =~ "" ]]; then + WIFIPASS=$(echo " Press Enter if network is saved" | rofi -dmenu -p " WiFi Password: " -lines 1 ) + fi + if nmcli dev wifi con "$CHSSID" password "$WIFIPASS" + then + notify-send 'Connection successful' + else + notify-send 'Connection failed' fi - nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && notify-send "Connection Established" "$success_message" fi fi