-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwifail
executable file
·25 lines (20 loc) · 1.37 KB
/
wifail
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
# Note: xterm's `-e` option seems to prepend `bash -c` to its argument (when necessary?);
# i.e., it starts a non-interactive shell.
# Check if a workspace named "wifail" exists.
workspace_exists=$(i3-msg -t get_workspaces | jq 'any (.name == "wifail")')
# Switch to the workspace named "wifail". Create it if necessary.
i3-msg 'workspace wifail'
# Exit if the "wifail" workspace already existed.
[[ $workspace_exists == 'true' ]] && exit
# Create an i3 workspace with 7 placeholder windows that swallow xterms.
i3-msg -q 'append_layout ~/.config/i3/wifail-workspace.json'
# Show the output of wpa_supplicant and dhcpcd from the current boot as if they were
# running in the foreground. See journalctl(1).
xterm -title wpa_supplicant -e 'journalctl -fu wpa_supplicant@wlan0 -n $(($(tput lines)-1)) -b -o cat' &
xterm -title dhcpcd -e 'journalctl -fu dhcpcd@wlan0 -n $(($(tput lines)-1)) -b -o cat' &
xterm -title 'iw wlan0 link' -e 'watch -n 1 iw wlan0 link' &
xterm -title 'ping gateway' -e 'while true; do a=$(ip r | awk '\''/^default via .* wlan/{print $3}'\''); [[ $a ]] && ping -c 8 "$a" && sleep 10 && clear || sleep 1; done' &
xterm -title 'ip address show wlan0' -e 'watch -d -n 1 ip address show wlan0' &
xterm -title route -e 'watch -d -n 1 route -n' &
xterm -title 'ping google.com' -e 'while true; do ping -c 8 google.com && sleep 10 && clear || sleep 1; done' &