refactor(waybar): improvements for network status
This includes a script to toggle all wireless devices
This commit is contained in:
parent
3630d7074a
commit
f511670032
@ -97,13 +97,14 @@
|
|||||||
"on-click": "swaylock"
|
"on-click": "swaylock"
|
||||||
},
|
},
|
||||||
"network": {
|
"network": {
|
||||||
"on-click-right": "iwctl station wlan0 disconnect",
|
"on-click-right": "~/.config/waybar/scripts/set-rfkill.bash",
|
||||||
"interval": 1,
|
"interval": 1,
|
||||||
"format-alt": " {bandwidthUpBytes} | {bandwidthDownBytes}",
|
"format-alt": " {bandwidthUpBytes} | {bandwidthDownBytes}",
|
||||||
"format-disconnected": "{icon} Disconnected",
|
"format-disconnected": "{icon} Disconnected",
|
||||||
"format-linked": " {ifname} | ↕ {bandwidthTotalBytes}",
|
"format-linked": " {ifname} | ↕ {bandwidthTotalBytes}",
|
||||||
"format-wifi": "{icon} {essid} | ↕ {bandwidthTotalBytes}",
|
"format-wifi": "{icon} {essid} | ↕ {bandwidthTotalBytes}",
|
||||||
"format-ethernet": "{icon} {ipaddr}/{cidr} | ↕ {bandwidthTotalBytes}",
|
"format-ethernet": "{icon} {ipaddr}/{cidr} | ↕ {bandwidthTotalBytes}",
|
||||||
|
"format-disabled": " Wireless Networking Disabled",
|
||||||
"tooltip-format": "{ifname}: {ipaddr}/{cidr} {gwaddr}",
|
"tooltip-format": "{ifname}: {ipaddr}/{cidr} {gwaddr}",
|
||||||
"format-icons": {
|
"format-icons": {
|
||||||
"ethernet": "",
|
"ethernet": "",
|
||||||
|
51
dots/.config/waybar/scripts/set-rfkill.bash
Executable file
51
dots/.config/waybar/scripts/set-rfkill.bash
Executable 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
|
@ -259,9 +259,13 @@
|
|||||||
color: #e6c384;
|
color: #e6c384;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#network.disabled {
|
||||||
|
color: #FF5D62;
|
||||||
|
}
|
||||||
|
|
||||||
/* Clock */
|
/* Clock */
|
||||||
#clock {
|
#clock {
|
||||||
color: #ff5d62;
|
color: #FF9E3B;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lock */
|
/* Lock */
|
||||||
|
Loading…
Reference in New Issue
Block a user