Created
December 8, 2023 19:03
-
-
Save SLeitgeb/85aa22ff5bfc79a4c05fc80776308f58 to your computer and use it in GitHub Desktop.
Waybar configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# scale=10; | |
pi=4*a(1); | |
e=e(1); | |
define sin(x) { | |
if (x == pi/2) { | |
return 1; | |
} | |
return s(x); | |
} | |
define cos(x) { | |
if (x == pi/2) { | |
return 0; | |
} | |
return c(x); | |
} | |
define tan(x) { | |
if (x == pi/4) { | |
return 1; | |
} | |
if (x == -pi/4) { | |
return -1; | |
} | |
return s(x)/c(x); | |
} | |
define cot(x) { | |
if (x == pi/4) { | |
return 1; | |
} | |
if (x == -pi/4) { | |
return -1; | |
} | |
return c(x)/s(x); | |
} | |
define sec(x) { | |
return 1/cos(x); | |
} | |
define csc(x) { | |
return 1/sin(x); | |
} | |
define asin(x) { | |
if (x == 1) { | |
return pi/2; | |
} | |
if (x == -1) { | |
return -pi/2; | |
} | |
return a(x/sqrt(1-x^2)); | |
} | |
define arcsin(x) { | |
return asin(x); | |
} | |
define acos(x) { | |
if (x == 0) { | |
return pi/2; | |
} | |
if (x == 1) { | |
return 0; | |
} | |
if (x == -1) { | |
return pi/1; | |
} | |
if (x > 0) { | |
return a(sqrt(1-x^2)/x); | |
} | |
return pi/1 - acos(-x); | |
} | |
define arccos(x) { | |
return acos(x); | |
} | |
define atan(x) { | |
if (x == 1) { | |
return pi/4; | |
} | |
if (x == -1) { | |
return -pi/4; | |
} | |
return a(x); | |
} | |
define arctan(x) { | |
return a(x); | |
} | |
define acot(x) { | |
return pi/2-atan(x); | |
} | |
define arccot(x) { | |
return acot(x); | |
} | |
define asec(x) { | |
if (x >= 1) { | |
return a(sqrt(x^2-1)); | |
} | |
return pi/1 - a(sqrt(x^2-1)); | |
} | |
define arcsec(x) { | |
return asec(x); | |
} | |
define acsc(x) { | |
if (x == 1) { | |
return pi/2; | |
} | |
if (x == -1) { | |
return -pi/2; | |
} | |
if (x > 1) { | |
return a(1/sqrt(x^2-1)); | |
} | |
return -a(1/sqrt(x^2-1)); | |
} | |
define arccsc(x) { | |
return acsc(x); | |
} | |
define ln(x) { | |
return l(x); | |
} | |
define log(a, b) { | |
return l(b)/l(a); | |
} | |
define lg(x) { | |
return log(10, x); | |
} | |
define log10(x) { | |
return log(10, x); | |
} | |
define log2(x) { | |
return log(2, x); | |
} | |
define pow(a, b) { | |
if (scale(b) == 0) { | |
return a ^ b; | |
} | |
return e(b*l(a)); | |
} | |
define exp(x) { | |
return e(x); | |
} | |
define cbrt(x) { | |
return pow(x, 1/3); | |
} | |
define abs(x) { | |
if (x < 0) { | |
return -x; | |
} | |
return x; | |
} | |
define bessel(n, x) { | |
return j(n,x); | |
} | |
define a(m, n) { | |
if (n < 0) { | |
return 0; | |
} | |
v = 1; | |
for (i = 0; i < n; i++) { | |
v *= (m - i); | |
} | |
return v; | |
} | |
define fac(n) { | |
return a(n, n); | |
} | |
define c(m, n) { | |
auto v | |
if (n < 0) { | |
return 0; | |
} | |
s = scale; | |
scale = 0; | |
v = a(m, n) / a(n, n); | |
scale = s; | |
return v; | |
} | |
define rad(deg) { | |
return deg/180*pi; | |
} | |
define deg(rad) { | |
return rad/pi*180; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"layer": "top", | |
"position": "top", | |
"modules-left": ["custom/menu", "sway/workspaces", "sway/mode", "sway/window"], | |
"modules-center": ["custom/sunrise", "clock", "custom/sunset"], | |
"modules-right": [ | |
"disk", | |
"custom/cpu", | |
"custom/gpu", | |
// "battery", | |
"tray", | |
"pulseaudio", | |
"network" | |
], | |
"custom/menu": { | |
"format": "Λ", | |
"on-click": "swaymsg exec \\$menu", | |
"tooltip": false, | |
}, | |
"sway/mode": { | |
"format": "{}", | |
"tooltip": false, | |
}, | |
"sway/window": { | |
"format": "{title}", | |
"max-length": 50, | |
"rewrite": { | |
"(.*)Discord": "Discord", | |
"(.+)": "| $1 ", | |
"": "", | |
}, | |
}, | |
"disk": { | |
"interval": 5, | |
"format": "<span color=\"gray\">DSK</span> {free}", | |
}, | |
"custom/sunrise": { | |
"interval": 60, | |
"format": " {} |", | |
"exec": "~/.config/waybar/solar.sh --sunrise", | |
}, | |
"custom/sunset": { | |
"interval": 60, | |
"format": "| {}", // \uf186 \ue226 | |
"exec": "~/.config/waybar/solar.sh --sunset", | |
}, | |
"clock": { | |
"interval": 60, | |
"format": "{:%b %e %Y %H:%M}", | |
"tooltip": true, | |
"tooltip-format": "<big>{:%B %Y}</big>\n<tt>{calendar}</tt>", | |
}, | |
"custom/cpu": { | |
"interval": 1, | |
"format": "<span color=\"gray\">CPU</span> {}", | |
"exec": "~/.config/waybar/cpu.sh", | |
// on-click: "swaymsg exec \"${config.home.sessionVariables.TERM} --class=floating -e ${config.home.sessionVariables.RESOURCE_MONITOR}\"", | |
"on-click": "swaymsg exec \"kitty --class=floating -e btop\"", | |
}, | |
"custom/gpu": { | |
"interval": 1, | |
"format": "<span color=\"gray\">GPU</span> {}", | |
"exec": "~/.config/waybar/gpu.sh", | |
// on-click: "swaymsg exec \"${config.home.sessionVariables.TERM} --class=floating -e ${nvtop}\"", | |
"on-click": "swaymsg exec \"kitty --class=floating -e nvtop\"", | |
}, | |
"battery": { | |
"format": "<span color=\"gray\">BAT</span> {capacity}%", | |
}, | |
"tray": { | |
"icon-size": 18, | |
"spacing": 5, | |
"reverse-direction": true, | |
}, | |
"pulseaudio": { | |
"scroll-step": 5, | |
"format": "<span color=\"gray\">VOL</span> {volume}%", | |
"format-muted": "<span strikethrough=\"true\" color=\"gray\">VOL</span>", | |
"tooltip-format": "VOL {volume}%", | |
// on-click: "swaymsg exec \"${config.home.sessionVariables.TERM} --class=floating -e pulsemixer\"", | |
"on-click": "swaymsg exec \"kitty --class=floating -e pulsemixer\"", | |
}, | |
"network": { | |
"interval": 5, | |
"format-wifi": "<span color=\"gray\">WIFI</span>", | |
"format-ethernet": "<span color=\"gray\">ETH</span>", | |
"format-disconnected": "<span strikethrough=\"true\" color=\"gray\">ETH</span>", | |
"tooltip-format": "{ifname} ({essid}): {ipaddr}", | |
// on-click: "swaymsg exec \"${config.home.sessionVariables.TERM} --class=floating -e nmtui\"", | |
"on-click": "swaymsg exec \"kitty --class=floating -e nmtui\"", | |
}, | |
} | |
// vim:ft=jsonc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# source: | |
# https://git.sr.ht/~sntx/flake/tree/main/item/modules/pkgs-usr/waybar/waybar-custom-cpu.sh | |
load=$(expr 100 - $(vmstat 1 2|tail -1|awk '{print $15}'))% | |
Memtotal=$(cat /proc/meminfo | rg "^MemTotal:" | sed -E 's/\S*\s*//' | sed -E 's/ kB//') | |
Shmem=$(cat /proc/meminfo | rg "^Shmem:" | sed -E 's/\S*\s*//' | sed -E 's/ kB//') | |
MemFree=$(cat /proc/meminfo | rg "^MemFree:" | sed -E 's/\S*\s*//' | sed -E 's/ kB//') | |
Buffers=$(cat /proc/meminfo | rg "^Buffers:" | sed -E 's/\S*\s*//' | sed -E 's/ kB//') | |
Cached=$(cat /proc/meminfo | rg "^Cached:" | sed -E 's/\S*\s*//' | sed -E 's/ kB//') | |
SReclaimable=$(cat /proc/meminfo | rg "^SReclaimable:" | sed -E 's/\S*\s*//' | sed -E 's/ kB//') | |
# mem=$(awk "BEGIN {print (($Memtotal + $Shmem - $MemFree - $Buffers - $Cached - $SReclaimable)/$Memtotal)*100}" | sed 's/\..*//')% | |
mem=$(awk "BEGIN {print ($Memtotal + $Shmem - $MemFree - $Buffers - $Cached - $SReclaimable)/1024}" | sed 's/\..*//')M | |
if [ -e /sys/class/hwmon/hwmon2/temp1_input ]; then | |
temp=$(($(cat /sys/class/hwmon/hwmon2/temp1_input) / 1000))C | |
# temp=$(awk "BEGIN {print ($(cat /sys/class/hwmon/hwmon2/temp1_input) / 1000 + 273.15)}" | sed 's/\..*//')K | |
echo $load $mem $temp | |
elif [ -e /sys/class/hwmon/hwmon1/temp1_input ]; then | |
temp=$(($(cat /sys/class/hwmon/hwmon1/temp1_input) / 1000))C | |
# temp=$(awk "BEGIN {print ($(cat /sys/class/hwmon/hwmon1/temp1_input) / 1000 + 273.15)}" | sed 's/\..*//')K | |
echo $load $mem $temp | |
else | |
echo "!" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# source: | |
# https://git.sr.ht/~sntx/flake/tree/main/item/modules/pkgs-usr/waybar/waybar-custom-gpu.sh | |
# https://wiki.archlinux.org/title/AMDGPU#Manually | |
# GPU's P-states: cat /sys/class/drm/card1/device/pp_od_clk_voltage | |
# Monitor GPU: watch -n 0.5 cat /sys/kernel/debug/dri/0/amdgpu_pm_info | |
# GPU utilization: cat /sys/class/drm/card1/device/gpu_busy_percent | |
# GPU frequency: cat /sys/class/drm/card1/device/pp_dpm_sclk | |
# GPU temperature: cat /sys/class/drm/card1/device/hwmon/hwmon*/temp1_input | |
# VRAM frequency: cat /sys/class/drm/card1/device/pp_dpm_mclk | |
# VRAM usage: cat /sys/class/drm/card1/device/mem_info_vram_used | |
# VRAM size: cat /sys/class/drm/card1/device/mem_info_vram_total | |
gpu_path="/sys/class/drm/card1/device" | |
if [ -e $gpu_path/gpu_busy_percent ] && [ -e $gpu_path/mem_info_vram_used ] && [ -e $gpu_path/mem_info_vram_total ] && [ -e $gpu_path/hwmon/hwmon*/temp1_input ] | |
then | |
load=$(cat $gpu_path/gpu_busy_percent)% | |
mem_info_vram_used=$(cat $gpu_path/mem_info_vram_used) | |
mem_info_vram_total=$(cat $gpu_path/mem_info_vram_total) | |
# mem=$(awk "BEGIN {print ($mem_info_vram_used / $mem_info_vram_total) * 100}" | sed 's/\..*//')% | |
mem=$(awk "BEGIN {print $mem_info_vram_used / (1024 * 1024)}" | sed 's/\..*//')M | |
temp=$(cat $gpu_path/hwmon/hwmon*/temp1_input) | |
temp=$(expr $temp / 1000)C | |
# temp=$(awk "BEGIN {print ($temp / 1000 + 273.15)}" | sed 's/\..*//')K | |
echo $load $mem $temp | |
else | |
echo "!" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
LAT=49.2 | |
LON=16.6 | |
# calculations taken mostly from | |
# https://gml.noaa.gov/grad/solcalc/solareqns.PDF | |
# SCRIPT_DIR from: | |
# https://stackoverflow.com/a/246128/4297755 | |
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | |
BCRC=${SCRIPT_DIR}/.bcrc | |
bc="bc $BCRC -l" | |
UTC_HOUR=$(date -u +"%H") | |
HOUR=$(date +"%H") | |
HOUR_DIFF=$(echo "$HOUR - $UTC_HOUR" | bc) | |
DAY_OF_YEAR=$(date +"%j") | |
YEAR=$(date +"%Y") | |
# magic. tries parsing this year's 29th of February | |
# if it fails, it's not a leap year … | |
date -d $YEAR-02-29 &>/dev/null | |
NOT_A_LEAP_YEAR=$(echo $?) | |
# days in year | |
DIY=$(echo "$NOT_A_LEAP_YEAR + 365" | bc) | |
ZENITH=$(echo "rad(90.833)" | $bc) | |
# fractional year | |
FY=$(echo "2 * pi / $DIY * ($DAY_OF_YEAR - 1 + ($UTC_HOUR - 12) / 24)" | $bc) | |
EQTIME=$(echo "229.18*(0.000075 + 0.001868 * cos($FY) - 0.032077 * sin($FY) - 0.014615 * cos(2 * $FY) - 0.040849 * sin(2 * $FY) )" | $bc) | |
DECL=$(echo "0.006918 - 0.399912 * cos($FY) + 0.070257 * sin($FY) - 0.006758 * cos(2 * $FY) + 0.000907 * sin(2 * $FY) - 0.002697 * cos(3 * $FY) + 0.00148 * sin(3 * $FY)" | $bc) | |
HA=$(echo "arccos( ( cos($ZENITH) / cos(rad($LAT)) * cos($DECL) ) - tan(rad($LAT)) * tan($DECL))" | $bc) | |
while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do case $1 in | |
-r | --sunrise ) | |
SUNRISE_MIN=$(echo "720 - 4*($LON + deg($HA)) - $EQTIME + 60 * $HOUR_DIFF" | $bc) | |
RISE_HR=$(echo "$SUNRISE_MIN / 60" | bc) | |
echo $RISE_HR:$(echo "($SUNRISE_MIN - 60 * $RISE_HR)" | $bc | xargs printf %.0f) | |
exit | |
;; | |
-s | --sunset ) | |
SUNSET_MIN=$(echo "720 - 4*($LON - deg($HA)) - $EQTIME + 60 * $HOUR_DIFF" | $bc) | |
SET_HR=$(echo "$SUNSET_MIN / 60" | bc) | |
echo $SET_HR:$(echo "($SUNSET_MIN - 60 * $SET_HR)" | $bc | xargs printf %.0f) | |
exit | |
;; | |
esac; shift; done | |
if [[ "$1" == '--' ]]; then shift; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
color: #dddddd; | |
font-family: "Operator Mono"; | |
font-weight: 400; | |
/* font-family: "Fira Mono"; */ | |
/* font-weight: 700; */ | |
font-size: 16px; | |
border: none; | |
border-radius: 4px; | |
padding: 0px 0px 0px 0px; | |
margin: 0px 0px 0px 0px; | |
} | |
#waybar { | |
background: transparent; | |
} | |
.modules-left { | |
margin: 4px 0px 0px 4px; | |
} | |
.modules-right { | |
margin: 4px 4px 0px 0px; | |
} | |
.modules-center { | |
margin: 4px 4px 0px 4px; | |
} | |
.modules-left, | |
.modules-center, | |
.modules-right { | |
background: rgba(0, 0, 0, 0.75); | |
} | |
.modules-left { | |
padding-right: 4px; | |
} | |
.modules-right { | |
padding-left: 4px; | |
} | |
#mode, | |
#disk, | |
#custom-cpu, | |
#custom-gpu, | |
#custom-sunrise, | |
#custom-sunset, | |
#battery | |
{ | |
padding: 2px 4px 2px 4px; | |
} | |
#custom-menu { | |
background: rgba(0, 0, 0, 0.75); | |
border-radius: 4px 0px 0px 4px; | |
padding: 2px 8px 2px 8px; | |
} | |
#workspaces button { | |
border-radius: 0px; | |
padding: 2px 2px 2px 4px; | |
} | |
#workspaces button.focused { | |
background: rgba(80, 80, 80, 0.75); | |
} | |
#workspaces button.urgent { | |
background: rgba(100, 0, 0, 0.75); | |
} | |
#clock { | |
padding: 2px 8px 2px 8px; | |
} | |
#tray { | |
padding: 2px 4px 2px 4px; | |
} | |
#pulseaudio { | |
border-radius: 0px 0px 0px 0px; | |
padding: 2px 4px 2px 4px; | |
} | |
#network { | |
border-radius: 0px 4px 4px 0px; | |
padding: 2px 8px 2px 4px; | |
} | |
#pulseaudio, #network { | |
background: rgba(0, 0, 0, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment