Compare commits

...

2 Commits

3 changed files with 82 additions and 29 deletions

82
rofi/rofi-wifi-menu.sh Executable file
View File

@ -0,0 +1,82 @@
#!/usr/bin/env bash
FIELDS=SSID,SECURITY,ACTIVE
if [ -r "${HOME}/.dotfiles/rofi/wifi.rasi" ]; then
source "${HOME}/.dotfiles/rofi/wifi.rasi"
fi
CURRSSID=$(LANGUAGE=C nmcli -t -f active,bssid dev wifi | awk -F: '$1 ~ /^yes/ {print $2}')
LIST=$(nmcli --fields "$FIELDS" device wifi list | sed '/^--/d' | sed 's/no/ /' | sed 's/yes/* /')
# Gives a list of known connections so we can parse it later
KNOWNCON=$(nmcli connection show)
# Really janky way of telling if there is currently a connection
CONSTATE=$(nmcli -fields WIFI g)
if [[ "$CONSTATE" =~ "enabled" ]]; then
TOGGLE="Toggle Off"
elif [[ "$CONSTATE" =~ "disabled" ]]; then
TOGGLE="Toggle On"
fi
CHENTRY=$(echo -e "${TOGGLE}\nManual\n${LIST}" | rofi -dmenu -i -p "Wi-Fi SSID: " "" -width 45 -l 1 -theme ${HOME}/.dotfiles/rofi/sidebar.rasi)
# If the user inputs "manual" as their SSID in the start window, it will bring them to this screen
if [ "$CHENTRY" = "manual" ] ; then
#
# Manual entry of the SSID and password
MSSID=$(echo "enter the SSID of the network (SSID,password)" | rofi -dmenu -p "Manual Entry: " "" -width 45 -l 1 -theme ${HOME}/.dotfiles/rofi/sidebar.rasi)
MPASS=$(echo "$MSSID" | cut -d',' -f2-)
MSSID=$(echo "$MSSID" | cut -d',' -f1)
# If the user entered a manual password, then use the password nmcli command
if [ "$MPASS" = "" ]; then
nmcli dev wifi con "$MSSID"
else
nmcli dev wifi con "$MSSID" password "$MPASS"
fi
elif [ "$CHENTRY" = "Toggle On" ]; then
nmcli radio wifi on
elif [ "$CHENTRY" = "Toggle Off" ]; then
nmcli radio wifi off
else
# If the connection is already in use, then this will still be able to get the SSID
CHSSID=$(echo "$CHENTRY" | cut -d' ' -f1)
CURRSSID=$(echo "$CHENTRY" | grep '\*')
if [ -n "$CURRSSID" ]; then
nmcli con down "$CHSSID"
else
# Request password if required
if [[ "$CHENTRY" =~ "WPA2" ]] || [[ "$CHENTRY" =~ "WEP" ]]; then
# Automatically connect to known network
if grep -q "^$CHSSID" <<< "$KNOWNCON"; then
nmcli con up "$CHSSID"
else
WIFIPASS=$(echo "Password" | rofi -dmenu -p "Password: " "" -width 45 -l 1 -theme "${HOME}"/.dotfiles/rofi/sidebar.rasi)
# Attempt to connect with known password if none provided (should fail)
if [[ "$WIFIPASS" == "Password" ]]; then
nmcli dev wifi connect "$CHSSID"
# Connect with password
else
nmcli dev wifi con "$CHSSID" password "$WIFIPASS"
fi
fi
# Connect to unprotected wifi
else
RET=$(nmcli dev wifi connect "$CHSSID")
# Offer to open VPN menu
if [[ "$RET" =~ 'successfully activated' ]] && grep -qP "(wg|tun)0" <<< "$(ip addr)"; then
swaynag --message "This is public Wi-Fi and you are not using your VPN." -z "Open VPN settings?" "${HOME}/scripts/rofi/rofi-openvpn.sh"
fi
fi
fi
fi

View File

@ -1,15 +0,0 @@
[Unit]
Description=Sway window transparency daemon
PartOf=graphical-session.target
After=sway.service
[Service]
Type=simple
ExecStart=/var/home/jpm/scripts/sway/sway-transparency.sh
Restart=unless-stopped
Requires=dbus.service
After=dbus.service
TimeoutSec=5
[Install]
WantedBy=default.target

View File

@ -1,14 +0,0 @@
[Unit]
Description=Rotate through cropped wallpapers for %u
[Service]
Type=forking
#PIDFile=/var/home/%u/.spool/wallpaper.pid
WorkingDirectory=/var/home/%u/.spool
ExecStart=/var/home/%u/scripts/distrobox/debian12/wallpaper.pl
#ExecStart=/var/home/%u/scripts/distrobox/debian12/wallpaper.pl -d --path=/home/jpm/wallpapers `cat /var/home/%u/.spool/wallpaper_outputs`
Restart=always
TimeoutSec=5
[Install]
WantedBy=graphical.target