aboutsummaryrefslogtreecommitdiff
path: root/.config/tmux/left-status.sh
blob: afceea803d152699b88ccfd6ebea7e9592edb6ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

function ip-address() {
    # Loop through the interfaces and check for the interface that is up.
    for file in /sys/class/net/*; do
        iface=$(basename $file);
        read status < $file/operstate;
        [ "$status" == "up" ] && ip addr show $iface | awk '/inet /{printf $2" "}'
    done
}

function vpn-connection() {
    # Check for tun0 interface.
    [ -d /sys/class/net/tun0 ] && printf "%s " 'VPN*'
}

function main() {
    # Comment out any function you do not need. 
    ip-address
    vpn-connection
}

# Calling the main function which will call the other functions.
main