diff options
| author | Mitsuo Tokumori <[email protected]> | 2024-09-11 04:25:38 +0900 |
|---|---|---|
| committer | Mitsuo Tokumori <[email protected]> | 2024-09-11 04:25:38 +0900 |
| commit | 37ff7062874b72bafa99afe661f42653565ed511 (patch) | |
| tree | 60372bf7fdb94c9034c7d1cc5a17cd7df526c4fc /public/.local/bin/network_control.sh | |
| parent | dca319b8d9d221f1aaf3a00ee457d202096c66ac (diff) | |
| download | dotfiles-37ff7062874b72bafa99afe661f42653565ed511.tar.gz dotfiles-37ff7062874b72bafa99afe661f42653565ed511.tar.bz2 dotfiles-37ff7062874b72bafa99afe661f42653565ed511.zip | |
RESTRUCTURE. Replicate relative paths in public/
Diffstat (limited to 'public/.local/bin/network_control.sh')
| -rwxr-xr-x | public/.local/bin/network_control.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/public/.local/bin/network_control.sh b/public/.local/bin/network_control.sh new file mode 100755 index 0000000..4dc4b38 --- /dev/null +++ b/public/.local/bin/network_control.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +signal=30 + +# 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 + wifitoggle) toggle_wifi ;; + vpntoggle) toggle_vpn ;; + bluetoothtoggle) toggle_bluetooth ;; + isolatetoggle) toggle_network_quarantine ;; + *) + echo "invalid option :)" + ;; +esac + +send_signal |
