refactor(waybar): improvements for network status

This includes a script to toggle all wireless devices
This commit is contained in:
Price Hiller 2023-06-04 01:39:41 -05:00
parent 3630d7074a
commit f511670032
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8
3 changed files with 58 additions and 2 deletions

View File

@ -97,13 +97,14 @@
"on-click": "swaylock"
},
"network": {
"on-click-right": "iwctl station wlan0 disconnect",
"on-click-right": "~/.config/waybar/scripts/set-rfkill.bash",
"interval": 1,
"format-alt": " {bandwidthUpBytes} |  {bandwidthDownBytes}",
"format-disconnected": "{icon} Disconnected",
"format-linked": " {ifname} | ↕ {bandwidthTotalBytes}",
"format-wifi": "{icon} {essid} | ↕ {bandwidthTotalBytes}",
"format-ethernet": "{icon} {ipaddr}/{cidr} | ↕ {bandwidthTotalBytes}",
"format-disabled": "󰀝 Wireless Networking Disabled",
"tooltip-format": "{ifname}: {ipaddr}/{cidr} 󰌹 {gwaddr}",
"format-icons": {
"ethernet": "󰈀",

View File

@ -0,0 +1,51 @@
#!/usr/bin/env bash
main () {
local notify_application_name="RF Status"
local enable_airplane_mode=true
local unblocked_devices=""
local rf_soft_status
local rf_hard_status
local device
local device_type
for rf_status in $(rfkill -J | jq '.rfkilldevices[]' | jq -r tostring); do
rf_soft_status="$(printf "%s" "${rf_status}" | jq -r '.soft')"
rf_hard_status="$(printf "%s" "${rf_status}" | jq -r '.hard')"
device="$(printf "%s" "${rf_status}" | jq -r '.device')"
device_type="$(printf "%s" "${rf_status}" | jq -r '.type')"
printf "RF Status JSON: %s\n" "${rf_status}"
if [[ "${rf_soft_status}" == "blocked" ]]; then
enable_airplane_mode=false
unblocked_devices+=" - ${device} (${device_type})\n"
fi
if [[ "${rf_hard_status}" == "blocked" ]]; then
notify-send " Hard Block Detected In Network Device" "${device} (${device_type}) has a hard block!" -a "${notify_application_name}" -u "critical"
fi
done
if [[ "${enable_airplane_mode}" = true ]]; then
printf "Airplane mode to be enabled\n"
if rfkill block all; then
notify-send "󱡻 Enabled Airplane Mode" "All wireless network devices have been blocked!" -a "${notify_application_name}"
else
notify-send "󱡺 Failed to Enable Airplane Mode" "An error has occurred! Unable to modify rf status of some devices" -a "${notify_application_name}" -u "critical"
fi
else
printf "Airplane mode to be disabled\n"
if rfkill unblock all; then
notify-send "󱢂 Disabled Airplane Mode" "Unblocked Devices:\n${unblocked_devices}" -a "${notify_application_name}"
else
notify-send "󱡺 Failed to Disable Airplane Mode" "An error has occurred! Unable to modify rf status of some devices!" -a "${notify_application_name}" -u "critical"
fi
fi
}
main

View File

@ -259,9 +259,13 @@
color: #e6c384;
}
#network.disabled {
color: #FF5D62;
}
/* Clock */
#clock {
color: #ff5d62;
color: #FF9E3B;
}
/* Lock */