summaryrefslogtreecommitdiffstats
path: root/local/bin/network_control.sh
diff options
context:
space:
mode:
authorMitsuo Tokumori <[email protected]>2024-08-29 03:28:33 +0900
committerMitsuo Tokumori <[email protected]>2024-08-29 03:28:33 +0900
commita888e54f461edf2bc609e3d603a6f41d2ec27e7b (patch)
tree869a39bd0fe7d82123c1e4b845f504b1b5d8cc22 /local/bin/network_control.sh
parent5e1a0436d41ca2501aa6ee66f7494d99090bc7ed (diff)
downloaddotfiles-a888e54f461edf2bc609e3d603a6f41d2ec27e7b.tar.gz
dotfiles-a888e54f461edf2bc609e3d603a6f41d2ec27e7b.tar.bz2
dotfiles-a888e54f461edf2bc609e3d603a6f41d2ec27e7b.zip
Add scripts to control/monitor wireless devices
Diffstat (limited to 'local/bin/network_control.sh')
-rwxr-xr-xlocal/bin/network_control.sh48
1 files changed, 39 insertions, 9 deletions
diff --git a/local/bin/network_control.sh b/local/bin/network_control.sh
index 381cbec..4dc4b38 100755
--- a/local/bin/network_control.sh
+++ b/local/bin/network_control.sh
@@ -2,21 +2,51 @@
signal=30
-# signal dwmblocks to update volume block
+# signal dwmblocks to update network block
send_signal() {
pkill -RTMIN+$signal dwmblocks
}
+toggle_wifi() {
+ status=$(nmcli radio wifi)
+
+ if [ "$status" = "enabled" ]; then
+ nmcli radio wifi off
+ else
+ nmcli radio wifi on
+ fi
+}
+
+# This one is hard because it requires root, and the VPN interface name
+# 2 ways to toggle, using systemctl, or wg-quick(1)
+# This one might be better controled through a `dmenu` script.
+toggle_vpn() {
+ :
+}
+
+toggle_network_quarantine() {
+ # Check the status of all wireless devices
+ if rfkill list | grep -q "Soft blocked: no"; then
+ # not all blocked
+ rfkill block all
+ else
+ # all blocked
+ rfkill unblock all
+ fi
+}
+
+# WIP
+toggle_bluetooth() {
+ :
+}
+
case $1 in
- inc) pactl set-sink-volume @DEFAULT_SINK@ +$delta% ;;
- dec) pactl set-sink-volume @DEFAULT_SINK@ -$delta% ;;
- mutetoggle) pactl set-sink-mute @DEFAULT_SINK@ toggle ;;
- deafentoggle) pactl set-source-mute @DEFAULT_SOURCE@ toggle ;;
+ wifitoggle) toggle_wifi ;;
+ vpntoggle) toggle_vpn ;;
+ bluetoothtoggle) toggle_bluetooth ;;
+ isolatetoggle) toggle_network_quarantine ;;
*)
- echo Wifi:
- echo -e "\nBluetooth:"
- bluetoothctl show
- echo -e "\nEthernet:"
+ echo "invalid option :)"
;;
esac