Compare commits
No commits in common. "5cf1d64eaffc908c7d3fee7f78ba72953a746011" and "e8ccdafcf70dae6a7e8125d3ffbf0084db3fd956" have entirely different histories.
5cf1d64eaf
...
e8ccdafcf7
|
@ -4,9 +4,9 @@
|
||||||
"height": 24, // Waybar height
|
"height": 24, // Waybar height
|
||||||
// "width": 1366, // Waybar width
|
// "width": 1366, // Waybar width
|
||||||
// Choose the order of the modules
|
// Choose the order of the modules
|
||||||
"modules-left": ["hyprland/workspaces"],
|
"modules-left": ["hyprland/workspaces", "hyprland/mode", "custom/spotify"],
|
||||||
"modules-center": ["hyprland/window"],
|
"modules-center": ["hyprland/window"],
|
||||||
"modules-right": ["pulseaudio", "network", "custom/bandwidth", "cpu", "memory", "battery", "tray", "clock"],
|
"modules-right": ["pulseaudio", "network", "cpu", "memory", "battery", "tray", "clock"],
|
||||||
"hyprland/workspaces": {
|
"hyprland/workspaces": {
|
||||||
"disable-scroll": true,
|
"disable-scroll": true,
|
||||||
"all-outputs": false,
|
"all-outputs": false,
|
||||||
|
@ -23,6 +23,9 @@
|
||||||
"default": ""
|
"default": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"hyprland/mode": {
|
||||||
|
"format": "<span style=\"italic\">{}</span>"
|
||||||
|
},
|
||||||
"tray": {
|
"tray": {
|
||||||
// "icon-size": 21,
|
// "icon-size": 21,
|
||||||
"spacing": 10
|
"spacing": 10
|
||||||
|
@ -49,13 +52,10 @@
|
||||||
},
|
},
|
||||||
"network": {
|
"network": {
|
||||||
// "interface": "wlp2s0", // (Optional) To force the use of this interface
|
// "interface": "wlp2s0", // (Optional) To force the use of this interface
|
||||||
"format-wifi": "{essid} ({signalStrength}) ",
|
"format-wifi": "{essid} ({signalStrength}%) ",
|
||||||
"format-ethernet": "{ifname}: {ipaddr}/{cidr} ",
|
"format-ethernet": "{ifname}: {ipaddr}/{cidr} ",
|
||||||
"format-disconnected": "Disconnected ⚠"
|
"format-disconnected": "Disconnected ⚠"
|
||||||
},
|
},
|
||||||
"custom/bandwidth": {
|
|
||||||
"exec": "$HOME/.config/waybar/scripts/bandwidth"
|
|
||||||
},
|
|
||||||
"pulseaudio": {
|
"pulseaudio": {
|
||||||
//"scroll-step": 1,
|
//"scroll-step": 1,
|
||||||
"format": "{volume}% {icon}",
|
"format": "{volume}% {icon}",
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import subprocess
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
|
|
||||||
def default_interface():
|
|
||||||
process = subprocess.run(
|
|
||||||
["ip", "route"], check=True, text=True, capture_output=True
|
|
||||||
)
|
|
||||||
for line in process.stdout.splitlines():
|
|
||||||
if line.startswith("default via"):
|
|
||||||
return line.split()[4]
|
|
||||||
raise RuntimeError("No default interface found")
|
|
||||||
|
|
||||||
|
|
||||||
def get_rx_tx_bytes(iface):
|
|
||||||
with open("/proc/net/dev") as f:
|
|
||||||
for line in f:
|
|
||||||
line = line.strip()
|
|
||||||
if not line.startswith(f"{iface}:"):
|
|
||||||
continue
|
|
||||||
rx_bytes = int(line.split()[1])
|
|
||||||
tx_bytes = int(line.split()[9])
|
|
||||||
return rx_bytes, tx_bytes
|
|
||||||
raise RuntimeError(f"Interface {iface} not found")
|
|
||||||
|
|
||||||
|
|
||||||
def format_size(size):
|
|
||||||
power_labels = {0: "B", 1: "K", 2: "M", 3: "G", 4: "T"}
|
|
||||||
#kilo = 2**10
|
|
||||||
#power = 0
|
|
||||||
#while size > kilo:
|
|
||||||
# size /= kilo
|
|
||||||
# power += 1
|
|
||||||
power = 1
|
|
||||||
return f"{size/1024:3.0f} {power_labels[power]}"
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
refresh_interval = 1
|
|
||||||
rx_icon = " "
|
|
||||||
tx_icon = " "
|
|
||||||
num_left = "<span font='NotoSansMono'>"
|
|
||||||
num_right = "</span>"
|
|
||||||
fmt_str = (
|
|
||||||
f"{rx_icon}{num_left}{{rx}}{{unit_suffix}}{num_right} "
|
|
||||||
f"{tx_icon}{num_left}{{tx}}{{unit_suffix}}{num_right}"
|
|
||||||
)
|
|
||||||
unit_suffix = ""
|
|
||||||
iface = default_interface()
|
|
||||||
|
|
||||||
rx_bytes, tx_bytes = get_rx_tx_bytes(iface)
|
|
||||||
|
|
||||||
while True:
|
|
||||||
prev_rx_bytes, prev_tx_bytes = rx_bytes, tx_bytes
|
|
||||||
rx_bytes, tx_bytes = get_rx_tx_bytes(iface)
|
|
||||||
drx = format_size((rx_bytes - prev_rx_bytes) / refresh_interval)
|
|
||||||
dtx = format_size((tx_bytes - prev_tx_bytes) / refresh_interval)
|
|
||||||
line = fmt_str.format(rx=drx, tx=dtx, unit_suffix=unit_suffix)
|
|
||||||
print(line, flush=True)
|
|
||||||
sleep(refresh_interval)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
|
@ -10,6 +10,5 @@
|
||||||
:set tabstop=8
|
:set tabstop=8
|
||||||
:set softtabstop=0
|
:set softtabstop=0
|
||||||
:set splitright
|
:set splitright
|
||||||
:set belloff=all
|
|
||||||
|
|
||||||
:command Vterm vertical terminal
|
:command Vterm vertical terminal
|
|
@ -19,7 +19,7 @@ export EDITOR='vim'
|
||||||
# Custom
|
# Custom
|
||||||
|
|
||||||
alias ip="ip -c"
|
alias ip="ip -c"
|
||||||
alias ls="ls -A --color"
|
alias ls="ls -A"
|
||||||
alias sl="sl -adew5F"
|
alias sl="sl -adew5F"
|
||||||
|
|
||||||
cat() {
|
cat() {
|
||||||
|
|
Loading…
Reference in New Issue