Skip to content

Commit

Permalink
Add gpu status; modify vpn status to work with protonvpn community
Browse files Browse the repository at this point in the history
  • Loading branch information
keystroke3 committed May 7, 2024
1 parent a51591f commit d5b1cd3
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 44 deletions.
25 changes: 18 additions & 7 deletions .config/waybar/config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"custom/vpnstatus",
"cpu",
"memory",
"custom/gpuinfo",
"pulseaudio",
"tray",
"clock"
Expand Down Expand Up @@ -134,13 +135,13 @@
]
},
"memory": {
"format": "󰍛 {}%",
"format-alt": "󰍛 {used}/{total} GiB",
"format": " {}%",
"format-alt": " {used}/{total} GiB",
"interval": 5
},
"cpu": {
"format": "󰻠 {usage}%",
"format-alt": "󰻠 {avg_frequency} GHz",
"format": " 󰍛 {usage}%",
"format-alt": "󰍛 {avg_frequency} GHz",
"interval": 5
},
"disk": {
Expand All @@ -151,10 +152,10 @@
},
"network": {
"format-wifi": "󰤨",
"format-ethernet": " {bandwidthDownBytes}",
"format-linked": " {ifname} (No IP)",
"format-ethernet": "󰈀 {bandwidthDownBytes}",
"format-linked": "󰈀 {ifname} (No IP)",
"format-disconnected": "󰤭",
"format-alt": " {ipaddr}",
"format-alt": "󰈀 {ipaddr}",
"tooltip-format": "{essid}",
"interval": 1,
"on-click-right": "nm-connection-editor"
Expand Down Expand Up @@ -210,6 +211,16 @@
// "all-outputs": "true",
// "return-type": "string"
},
"custom/gpuinfo": {
"format": "󰢮 {}",
"interval": 5,
"exec": "exec $HOME/.config/waybar/scripts/gpu_info m",
"tooltip": "false",
"signal": 8,
"on-click": "exec $HOME/.config/waybar/scripts/gpu_info m",
// "all-outputs": "true",
// "return-type": "string"
},
"custom/launcher": {
"format": "󰈸",
"on-click": "bash $HOME/.config/rofi/launcher.sh",
Expand Down
16 changes: 16 additions & 0 deletions .config/waybar/scripts/gpu_info
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
mem_used=$(cat /sys/class/hwmon/hwmon3/device/mem_info_vram_used)
mem_total=$(cat /sys/class/hwmon/hwmon3/device/mem_info_vram_total)
gpu_busy=$(cat /sys/class/hwmon/hwmon3/device/gpu_busy_percent)

mem_usage=$(bc <<< "scale=2; $mem_used / 1048576")

if [ "$1" = "m" ]; then
mem_usage=$(bc <<< "scale=2; $mem_used / 1073741824")
printf "%s%% | %.2fGB" "$gpu_busy" "$mem_usage"
else
mem_usage=$(bc <<< "scale=2; ($mem_used * 100) / $mem_total")
printf "%s%% | %.2f%%" "$gpu_busy" "$mem_usage"
fi


10 changes: 8 additions & 2 deletions .config/waybar/scripts/vpnstatus
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/bin/bash
if ip a | grep 'tun' -q;then
printf "$(ps -p $(pgrep -f openvpn) -o cmd --no-headers | cut -d' ' -f3 | rev | cut -d'/' -f1 | rev | cut -d'.' -f1 | tr '[:lower:]' '[:upper:]')"
if ip a | grep -iE 'tun|proton' -q;then
if [ -f /tmp/last_cc ]; then
printf "$(cat /tmp/last_cc)"
else
curl -s 'https://api.myip.com' | jq .cc | sed 's/"//g' > /tmp/last_cc
fi
# printf " $(ps -p $(pgrep -f openvpn) -o cmd --no-headers | cut -d' ' -f3 | rev | cut -d'/' -f1 | rev | cut -d'.' -f1 | tr '[:lower:]' '[:upper:]')"
else
[ -f /tmp/last_cc ] && rm /tmp/lastvpn
printf ""
fi

88 changes: 53 additions & 35 deletions .config/waybar/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ window#waybar {
}

#workspaces {
background: #282828;
margin: 0 5px;
padding: 0px 5px 0px 5px;
border-radius: 8px;
border: solid 0px #f4d9e1;
font-weight: normal;
font-style: normal;
background: #282828;
margin: 0 5px;
padding: 0px 5px 0px 5px;
border-radius: 8px;
border: solid 0px #f4d9e1;
font-weight: normal;
font-style: normal;
}

#workspaces button {
padding: 0px 5px;
border-radius: 8px;
Expand All @@ -36,32 +37,38 @@ window#waybar {
}

#workspaces button:hover {
background-color: #E6B9C6;
color: black;
border-radius: 8px;
background-color: #E6B9C6;
color: black;
border-radius: 8px;
}

#custom-date, #clock, #battery, #pulseaudio, #network, #custom-randwall, #custom-launcher {
background: transparent;
padding: 5px 5px 5px 5px;
margin: 0 5px;
#custom-date,
#clock,
#battery,
#pulseaudio,
#network,
#custom-randwall,
#custom-launcher {
background: transparent;
padding: 5px 5px 5px 5px;
margin: 0 5px;
border-radius: 8px;
border: solid 0px #f4d9e1;
}

#custom-date {
color: #D3869B;
color: #D3869B;
}

#custom-power {
color: #24283b;
background-color: #db4b4b;
border-radius: 5px;
margin-right: 10px;
margin-top: 5px;
margin-bottom: 5px;
margin-left: 0px;
padding: 5px 10px;
color: #24283b;
background-color: #db4b4b;
border-radius: 5px;
margin-right: 10px;
margin-top: 5px;
margin-bottom: 5px;
margin-left: 0px;
padding: 5px 10px;
}

#tray {
Expand Down Expand Up @@ -155,18 +162,18 @@ window#waybar {
}

#custom-playerctl {
background: #282828;
padding-left: 15px;
padding-right: 14px;
border-radius: 8px;
/*border-left: solid 1px #282738;*/
/*border-right: solid 1px #282738;*/
margin-top: 5px;
margin-bottom: 5px;
margin-left: 0px;
font-weight: normal;
font-style: normal;
font-size: 16px;
background: #282828;
padding-left: 15px;
padding-right: 14px;
border-radius: 8px;
/*border-left: solid 1px #282738;*/
/*border-right: solid 1px #282738;*/
margin-top: 5px;
margin-bottom: 5px;
margin-left: 0px;
font-weight: normal;
font-style: normal;
font-size: 16px;
}

#custom-playerlabel {
Expand Down Expand Up @@ -201,6 +208,17 @@ window#waybar {
background-color: #1E1E2E;
}

#custom-gpuinfo {
background-color: #282828;
/*color: #FABD2D;*/
border-radius: 8px;
margin: 0 5px;
margin-left: 5px;
margin-right: 5px;
padding: 0px 10px 0px 10px;
font-weight: bold;
}

#cpu {
background-color: #282828;
/*color: #FABD2D;*/
Expand Down
1 change: 1 addition & 0 deletions dev-packages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker-buildx
1 change: 1 addition & 0 deletions packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ yt-dlp
cronie
bind
7zip
distutils

0 comments on commit d5b1cd3

Please sign in to comment.