diff options
Diffstat (limited to 'home-manager/config/yambar')
-rw-r--r-- | home-manager/config/yambar/config/config.yml | 14 | ||||
-rw-r--r-- | home-manager/config/yambar/default.nix | 39 | ||||
-rw-r--r-- | home-manager/config/yambar/scripts/disk.sh | 26 | ||||
-rw-r--r-- | home-manager/config/yambar/scripts/grades-average.sh | 15 | ||||
-rw-r--r-- | home-manager/config/yambar/scripts/network.sh | 53 | ||||
-rwxr-xr-x | home-manager/config/yambar/scripts/old/amixer-monitor (renamed from home-manager/config/yambar/scripts/amixer-monitor) | 0 | ||||
-rwxr-xr-x | home-manager/config/yambar/scripts/old/cpu (renamed from home-manager/config/yambar/scripts/cpu) | 0 | ||||
-rwxr-xr-x | home-manager/config/yambar/scripts/old/dfspace (renamed from home-manager/config/yambar/scripts/dfspace) | 0 | ||||
-rwxr-xr-x | home-manager/config/yambar/scripts/old/grades-average (renamed from home-manager/config/yambar/scripts/grades-average) | 0 | ||||
-rwxr-xr-x | home-manager/config/yambar/scripts/old/meminfo (renamed from home-manager/config/yambar/scripts/meminfo) | 0 | ||||
-rwxr-xr-x | home-manager/config/yambar/scripts/old/nmclitest (renamed from home-manager/config/yambar/scripts/nmclitest) | 0 | ||||
-rwxr-xr-x | home-manager/config/yambar/scripts/old/pingtest (renamed from home-manager/config/yambar/scripts/pingtest) | 0 | ||||
-rwxr-xr-x | home-manager/config/yambar/scripts/old/yambar-tray (renamed from home-manager/config/yambar/scripts/yambar-tray) | 0 | ||||
-rwxr-xr-x | home-manager/config/yambar/scripts/old/yambar-tray-width (renamed from home-manager/config/yambar/scripts/yambar-tray-width) | 0 | ||||
-rw-r--r-- | home-manager/config/yambar/scripts/sound-volume.sh | 22 |
15 files changed, 161 insertions, 8 deletions
diff --git a/home-manager/config/yambar/config/config.yml b/home-manager/config/yambar/config/config.yml index f9b044c0..adf38f3d 100644 --- a/home-manager/config/yambar/config/config.yml +++ b/home-manager/config/yambar/config/config.yml @@ -147,7 +147,7 @@ bar: carrier: {empty: {}} - script: # Sound volume - path: /home/dt/.config/yambar/scripts/amixer-monitor + path: @volume_script@ content: map: on-click: /bin/sh -c "pavucontrol" @@ -158,25 +158,29 @@ bar: deco: *bgcurg ~muted: string: {text: " {volume}% ", deco: *combutil} + - script: # Grade average - path: /home/dt/.config/yambar/scripts/grades-average + path: @grade_average_script@ poll-interval: 10 content: string: text: " {grade} " deco: *combmem + #- backlight: # name: intel_backlight # content: # - string: {text: " {percent}% ", deco: *combutil} + - script: # CPU - path: /home/dt/.config/yambar/scripts/cpu + path: @cpu_script@ content: string: text: " {cpu}% " deco: *combmem + - script: # Memory info - path: /home/dt/.config/yambar/scripts/meminfo + path: @memory_script@ content: map: conditions: @@ -189,7 +193,7 @@ bar: text: " {memperc}% " deco: *combmem - script: # Disk space - path: /home/dt/.config/yambar/scripts/dfspace + path: @disk_script@ content: string: text: " {diskspace}({diskperc})" diff --git a/home-manager/config/yambar/default.nix b/home-manager/config/yambar/default.nix index e288d8ef..75f2afdc 100644 --- a/home-manager/config/yambar/default.nix +++ b/home-manager/config/yambar/default.nix @@ -1,10 +1,43 @@ { config, + sysLib, pkgs, + grades, + yambar_cpu, + yambar_memory, ... -}: { - xdg.configFile."yambar/config.yml".source = ./config/config.yml; - xdg.configFile."yambar/scripts".source = ./scripts; +}: let + makeScript = { + file, + dependencies, + ... + }: + sysLib.makeShellScriptWithLibrary { + name = "${builtins.baseNameOf file}"; + script = file; + dependencies = dependencies ++ (builtins.attrValues {inherit (pkgs) dash;}); + } + + "/bin/${builtins.baseNameOf file}"; +in { + xdg.configFile."yambar/config.yml".source = builtins.substitueAll { + src = ./config/config.yml; + + volume_script = makeScript { + dependencies = builtins.attrValues {inherit (pkgs) pactl gawk;}; + file = ./scripts/sound-volume.sh; + }; + grade_average_script = makeScript { + dependencies = [grades]; + file = ./scripts/grades-average.sh; + }; + cpu_script = yambar_cpu; + memory_script = yambar_memory; + + disk_script = makeScript { + dependencies = builtins.attrValues {inherit (pkgs) gawk btrfs-progs coreutils;}; + file = ./scripts/disk.sh; + }; + }; } # vim: ts=2 diff --git a/home-manager/config/yambar/scripts/disk.sh b/home-manager/config/yambar/scripts/disk.sh new file mode 100644 index 00000000..568ac71e --- /dev/null +++ b/home-manager/config/yambar/scripts/disk.sh @@ -0,0 +1,26 @@ +#! /usr/bin/env dash +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +# . ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH + + +# Main loop +while true; do + # vars + used_space=$(btrfs filesystem usage / 2> /dev/null | awk '{if ( /Used:/ ) { print $2 } } ' | head -n1) + all_space=$(btrfs filesystem usage / 2> /dev/null | awk '{if ( /Device size:/ ) { print $3 } } ' | head -n1 | tr -d "GiB") + + + # Check space available (4) and percentage used (5) + spaceperc=$(echo "$(echo "$used_space" | tr -d "GiB" )" "$all_space" | awk '{div=$1/$2;div *= 100; printf"%2d%%\n",div }') + + echo "diskspace|string|$used_space" + echo "diskperc|string|$spaceperc" + echo "" + sleep 1 +done + + + +# vim: ft=sh diff --git a/home-manager/config/yambar/scripts/grades-average.sh b/home-manager/config/yambar/scripts/grades-average.sh new file mode 100644 index 00000000..72e180bd --- /dev/null +++ b/home-manager/config/yambar/scripts/grades-average.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env dash +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. %SHELL_LIBRARY_PATH + + +while true; do + grade=$(grades list average | awk '{print $2}'); + + echo "grade|string|$grade"; + echo ""; + + sleep 1; +done +# vim: ft=sh diff --git a/home-manager/config/yambar/scripts/network.sh b/home-manager/config/yambar/scripts/network.sh new file mode 100644 index 00000000..9d797e15 --- /dev/null +++ b/home-manager/config/yambar/scripts/network.sh @@ -0,0 +1,53 @@ +#! /usr/bin/env dash +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +#. ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH + +LIB_TEMP_DIR_FOR_SCRIPT=$(mktemp -d) + +retest=120 +retest_if_con_fails=10 +backend=nmcli + +case "$backend" in + "nmcli") # Test for connectivity with nmcli + while true; do + connection_status=$(nmcli networking connectivity) + if [ "$connection_status" = "full" ]; then + echo "internet|string|Connected" + echo "" + sleep $retest + else + echo "internet|string|Disconnected" + echo "" + sleep $retest_if_con_fails + fi + done + ;; + "ping") # Test for connectivity with ping + ip_address='8.8.8.8' + ping_number=3 + + while true; do + + ping_result=$(mktmp) + ping $ip_address -c $ping_number -q | awk 'BEGIN {FS="/"} END {print $5}' > $ping_result + + if [ "$(cat $ping_result | wc -l)" -eq 0 ]; then + echo "med|string|No connection" + echo "" + sleep $retest_if_con_fails + else + echo "med|string|$(cat $ping_result) ms" + echo "" + sleep $retest + fi + done + ;; +esac + + + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi +# vim: ft=sh diff --git a/home-manager/config/yambar/scripts/amixer-monitor b/home-manager/config/yambar/scripts/old/amixer-monitor index 9e75acfa..9e75acfa 100755 --- a/home-manager/config/yambar/scripts/amixer-monitor +++ b/home-manager/config/yambar/scripts/old/amixer-monitor diff --git a/home-manager/config/yambar/scripts/cpu b/home-manager/config/yambar/scripts/old/cpu index bae820d0..bae820d0 100755 --- a/home-manager/config/yambar/scripts/cpu +++ b/home-manager/config/yambar/scripts/old/cpu diff --git a/home-manager/config/yambar/scripts/dfspace b/home-manager/config/yambar/scripts/old/dfspace index 0b262481..0b262481 100755 --- a/home-manager/config/yambar/scripts/dfspace +++ b/home-manager/config/yambar/scripts/old/dfspace diff --git a/home-manager/config/yambar/scripts/grades-average b/home-manager/config/yambar/scripts/old/grades-average index a04b958c..a04b958c 100755 --- a/home-manager/config/yambar/scripts/grades-average +++ b/home-manager/config/yambar/scripts/old/grades-average diff --git a/home-manager/config/yambar/scripts/meminfo b/home-manager/config/yambar/scripts/old/meminfo index 0156e94c..0156e94c 100755 --- a/home-manager/config/yambar/scripts/meminfo +++ b/home-manager/config/yambar/scripts/old/meminfo diff --git a/home-manager/config/yambar/scripts/nmclitest b/home-manager/config/yambar/scripts/old/nmclitest index 3e8bc73a..3e8bc73a 100755 --- a/home-manager/config/yambar/scripts/nmclitest +++ b/home-manager/config/yambar/scripts/old/nmclitest diff --git a/home-manager/config/yambar/scripts/pingtest b/home-manager/config/yambar/scripts/old/pingtest index 2b5f9998..2b5f9998 100755 --- a/home-manager/config/yambar/scripts/pingtest +++ b/home-manager/config/yambar/scripts/old/pingtest diff --git a/home-manager/config/yambar/scripts/yambar-tray b/home-manager/config/yambar/scripts/old/yambar-tray index 1704c6dd..1704c6dd 100755 --- a/home-manager/config/yambar/scripts/yambar-tray +++ b/home-manager/config/yambar/scripts/old/yambar-tray diff --git a/home-manager/config/yambar/scripts/yambar-tray-width b/home-manager/config/yambar/scripts/old/yambar-tray-width index 00544e70..00544e70 100755 --- a/home-manager/config/yambar/scripts/yambar-tray-width +++ b/home-manager/config/yambar/scripts/old/yambar-tray-width diff --git a/home-manager/config/yambar/scripts/sound-volume.sh b/home-manager/config/yambar/scripts/sound-volume.sh new file mode 100644 index 00000000..8fc0107f --- /dev/null +++ b/home-manager/config/yambar/scripts/sound-volume.sh @@ -0,0 +1,22 @@ +#! /usr/bin/env dash +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +# . ~/.local/lib/shell/lib +. %SHELL_LIBRARY_PATH + +while true; do + volume=$(pactl get-sink-volume 0 | awk 'BEGIN { FS="/" } {gsub("%","",$2); gsub(" ","",$2)} {printf $2}') + + if [ "$volume" -eq 0 ]; then + echo "muted|bool|true" + else + echo "volume|string|$volume" + echo "muted|bool|false" + fi + echo "" + + sleep 1; +done + + +# vim: ft=sh |