summaryrefslogtreecommitdiff
path: root/scripts/sysinfo
blob: 90bac9add3910bf9a319b154130729e404cbe155 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

batperc=$(cat /sys/class/power_supply/BAT0/capacity)
batstate=$(cat /sys/class/power_supply/BAT0/status)
brightness=$(brightnessctl -m | cut -d, -f 4)

network_info() {
    device=$(ip a | grep "state UP" | awk -F': ' '{ printf($2) }')
    case "${device}" in
        wlan*)
            network=$(iwctl station ${device} show | grep 'Connected network' \
                | awk -F' ' '{ printf($3) }')
            echo "${device}: ${network}"
            ;;
        eth*)
            echo "${device}: ${network}"
            ;;
    esac
}

get_volume() {
    wpctl get-volume @DEFAULT_SINK@ | awk -F' ' '{ printf "%s %s%% %s", $1, ($2 * 100), $3; }'
}

if [ "$TERM" = "linux" ]; then
    notify-send \
        "System Info:" \
        "\
Time: $(date "+%I:%M:%S")
$(get_volume)
Brightness: ${brightness}
${batstate}: ${batperc}%
$(network_info)"
else
    echo "\
Time: $(date "+%I:%M:%S")
$(get_volume)
Brightness: ${brightness}
${batstate}: ${batperc}%
$(network_info)"
fi