This commit is contained in:
Clay Gomera 2022-01-08 22:53:03 -04:00
parent d1f6270794
commit 9c46cb4d42
5 changed files with 106 additions and 21 deletions

View file

@ -343,6 +343,10 @@ globalkeys = my_table.join(
{description = "show rofi window menu", group = "hotkeys"}), {description = "show rofi window menu", group = "hotkeys"}),
awful.key({ modkey }, "w", function () awful.util.spawn("/home/drk/.shell-scripts/./rofi-wifi-menu.sh") end, awful.key({ modkey }, "w", function () awful.util.spawn("/home/drk/.shell-scripts/./rofi-wifi-menu.sh") end,
{description = "show rofi wifi menu", group = "hotkeys"}), {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 -- Keyboard Layouts
awful.key({ modkey, "Shift" }, "e", function () awful.util.spawn("setxkbmap -layout es") end, awful.key({ modkey, "Shift" }, "e", function () awful.util.spawn("setxkbmap -layout es") end,
@ -574,6 +578,8 @@ clientbuttons = gears.table.join(
root.keys(globalkeys) root.keys(globalkeys)
#+end_src #+end_src
#+RESULTS:
* Rules * 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. 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 #+begin_src lua

View file

@ -258,6 +258,10 @@ globalkeys = my_table.join(
{description = "show rofi window menu", group = "hotkeys"}), {description = "show rofi window menu", group = "hotkeys"}),
awful.key({ modkey }, "w", function () awful.util.spawn("/home/drk/.shell-scripts/./rofi-wifi-menu.sh") end, awful.key({ modkey }, "w", function () awful.util.spawn("/home/drk/.shell-scripts/./rofi-wifi-menu.sh") end,
{description = "show rofi wifi menu", group = "hotkeys"}), {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 -- Keyboard Layouts
awful.key({ modkey, "Shift" }, "e", function () awful.util.spawn("setxkbmap -layout es") end, awful.key({ modkey, "Shift" }, "e", function () awful.util.spawn("setxkbmap -layout es") end,

View file

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

View file

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

54
shell-scripts/rofi-wifi-menu.sh Normal file → Executable file
View file

@ -1,38 +1,50 @@
#!/usr/bin/env bash #!/usr/bin/env bash
notify-send "Getting list of available Wi-Fi networks..." 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 # 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) # get current connection status
if [[ "$connected" =~ "enabled" ]]; then CONSTATE=$(nmcli -fields WIFI g)
toggle="睊 Disable Wi-Fi" if [[ "$CONSTATE" =~ "enabled" ]]; then
elif [[ "$connected" =~ "disabled" ]]; then TOGGLE="Disable WiFi 睊"
toggle="直 Enable Wi-Fi" elif [[ "$CONSTATE" =~ "disabled" ]]; then
TOGGLE="Enable WiFi 直"
fi fi
# Use rofi to select wifi network # 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 # 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 if [ "$CHENTRY" = "" ]; then
exit exit
elif [ "$chosen_network" = "直 Enable Wi-Fi" ]; then elif [ "$CHENTRY" = "Enable WiFi 直" ]; then
nmcli radio wifi on nmcli radio wifi on
elif [ "$chosen_network" = "睊 Disable Wi-Fi" ]; then elif [ "$CHENTRY" = "Disable WiFi 睊" ]; then
nmcli radio wifi off nmcli radio wifi off
else else
# Message to show when connection is activated successfully # get list of known connections
success_message="You are now connected to the Wi-Fi network \"$chosen_id\"." KNOWNCON=$(nmcli connection show)
# Get saved connections
saved_connections=$(nmcli -g NAME connection) # If the connection is already in use, then this will still be able to get the SSID
if [[ $(echo "$saved_connections" | grep -w "$chosen_id") = "$chosen_id" ]]; then if [ "$CHSSID" = "*" ]; then
nmcli connection up id "$chosen_id" | grep "successfully" && notify-send "Connection Established" "$success_message" 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 else
if [[ "$chosen_network" =~ "" ]]; then if [[ "$CHENTRY" =~ "" ]]; then
wifi_password=$(rofi -dmenu -p "Password: " ) 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 fi
nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && notify-send "Connection Established" "$success_message"
fi fi
fi fi