diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index a33914f..36fdbb2 100755 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -21,8 +21,10 @@ ]; documentation.man.generateCaches = true; # used for the man script + + hardware.bluetooth.enable = true; -qt.enable = true; + qt.enable = true; # grub theme boot.loader.grub = { diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index c5526e1..a371861 100755 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -21,7 +21,7 @@ ../../modules/home-manager/neovim.nix # dont use nixvim. broken #../../modules/home-manager/neovim2.nix # ./neovim2.nix uses vim plug instead of the nix repository as with ./neovim.nix see the begining of neovim2 for an explanation ../../modules/home-manager/rclone.nix - #../../modules/home-manager/waybar.nix + ../../modules/home-manager/waybar.nix ../../modules/home-manager/quickshell.nix # used for widgets, waybar and notifications #../../modules/home-manager/oh-my-posh.nix # zsh customizer ../../modules/home-manager/oh-my-zsh.nix # another zsh customizer diff --git a/modules/scripts/QSsysinfo.nix b/modules/scripts/QSsysinfo.nix index 9519622..6a0d928 100644 --- a/modules/scripts/QSsysinfo.nix +++ b/modules/scripts/QSsysinfo.nix @@ -1,20 +1,55 @@ { - writeShellApplication, - ripgrep, - gawkInteractive, - ... +writeShellApplication, +ripgrep, +gawkInteractive, +iproute2, +coreutils, +procps, +upower, +... }: writeShellApplication { - name = "QS-sysinfo"; - runtimeInputs = [ - ripgrep - gawkInteractive - ]; - text = '' - Pad CPU, MEM, DISK to 2 chars (right-aligned) +name = "QS-sysinfo"; +runtimeInputs = [ + ripgrep + gawkInteractive + iproute2 + coreutils + procps + upower +]; +text = '' +# Pad CPU, MEM, DISK to 2 chars (right-aligned) + cpu=$(awk '/^cpu /{printf("%.0f", ($2+$4)*100/($2+$4+$5))}' /proc/stat) cpu=$(printf "%2s" "$cpu") +sum=0 +count=0 + +for f in /sys/class/hwmon/hwmon*/temp*_input; do + if [ -r "$f" ]; then + val=$(cat "$f" 2>/dev/null) || continue + sum=$((sum + val)) + count=$((count + 1)) + fi +done + +temp=$(( sum / count / 1000 )) + +sum=0 +count=0 + +for f in /sys/class/hwmon/hwmon*/fan*_input; do + if [ -r "$f" ]; then + val=$(cat "$f" 2>/dev/null) || continue + sum=$((sum + val)) + count=$((count + 1)) + fi +done +fan=$(( sum / count / 1000 )) +fan=$(printf "%4s" "$fan") + mem=$(free | awk '/Mem:/ {printf("%.0f",$3/$2*100)}') mem=$(printf "%2s" "$mem") @@ -25,7 +60,21 @@ disk=$(printf "%2s" "$disk") power=$(upower -b | awk -F: '/energy-rate/ {gsub(/^[ \t]+/, "", $2); split($2,a," "); printf("%.2f", a[1])}') power=$(printf "%5s" "$power") +# network calculations +iface=$(ip route get 1.1.1.1 | awk '{print $5; exit}') + +rx1=$(cat "/sys/class/net/$iface/statistics/rx_bytes") +tx1=$(cat "/sys/class/net/$iface/statistics/tx_bytes") + +sleep 1 + +rx2=$(cat "/sys/class/net/$iface/statistics/rx_bytes") +tx2=$(cat "/sys/class/net/$iface/statistics/tx_bytes") + +down_speed=$(( (rx2 - rx1) / 1024 )) +up_speed=$(( (tx2 - tx1) / 1024 )) + # Output JSON -echo "{\"cpu\":\"$cpu\",\"mem\":\"$mem\",\"disk\":\"$disk\",\"power\":\"$power\"}" - ''; +echo "{\"cpu\":\"$cpu\",\"temp\":\"$temp\",\"fan\":\"$fan\",\"mem\":\"$mem\",\"disk\":\"$disk\",\"power\":\"$power\",\"down\":\"$down_speed\",\"up\":\"$up_speed\"}" +''; } diff --git a/other/quickshell/bar/Bar.qml b/other/quickshell/bar/Bar.qml index 96bb457..d6543df 100644 --- a/other/quickshell/bar/Bar.qml +++ b/other/quickshell/bar/Bar.qml @@ -107,46 +107,65 @@ PanelWindow { smooth: false } - RowLayout { - id: sysinfo - spacing: 10 - - property int cpu: 0 - property int mem: 0 - property int disk: 0 - property real power: 0 - - Timer { - interval: 2000 - running: true - repeat: true - onTriggered: sysProcess.running = true - } - - Process { - id: sysProcess - command: ["QS-sysinfo"] - - stdout: SplitParser { - onRead: function(line) { - try { - var data = JSON.parse(line) - sysinfo.cpu = data.cpu - sysinfo.mem = data.mem - sysinfo.disk = data.disk - sysinfo.power = data.power - } catch(e) {} - } - } - } - - Text { - id: infoText - text: "CPU " + sysinfo.cpu + "% MEM " + sysinfo.mem + "% DSK " + sysinfo.disk + "% PWR " + sysinfo.power + "W" - font.pixelSize: 18 - color: Theme.Colors.barColor8 - } - } + RowLayout { + id: sysinfo + spacing: 10 + + property int cpu: 0 + property int mem: 0 + property int disk: 0 + property real power: 0 + property int temp: 0 + property int fan: 0 + property int down: 0 + property int up: 0 + + Timer { + interval: 2000 + running: true + repeat: true + onTriggered: sysProcess.running = true + } + + Process { + id: sysProcess + command: ["QS-sysinfo"] + + stdout: SplitParser { + onRead: function(line) { + try { + var data = JSON.parse(line) + + sysinfo.cpu = parseInt(data.cpu) + sysinfo.mem = parseInt(data.mem) + sysinfo.disk = parseInt(data.disk) + sysinfo.power = parseFloat(data.power) + sysinfo.temp = parseInt(data.temp) + sysinfo.fan = parseInt(data.fan) + sysinfo.down = parseInt(data.down) + sysinfo.up = parseInt(data.up) + + } catch(e) {} + } + } + } + + Column { + spacing: 2 + + Text { + text: "CPU " + sysinfo.cpu + "% | MEM " + sysinfo.mem + "% | PWR " + sysinfo.power.toFixed(1) + "W | UP " + sysinfo.up + font.pixelSize: 18 + color: Theme.Colors.barColor8 + } + + Text { + text: "TMP " + sysinfo.temp + "°C | DSK " + sysinfo.disk + "% | FAN " + sysinfo.fan + " | DOWN " + sysinfo.down + font.pixelSize: 18 + color: Theme.Colors.barColor8 + } + } + } } // ---------------- RIGHT MODULE ---------------- diff --git a/todo b/todo index e2958fb..1f2641e 100644 --- a/todo +++ b/todo @@ -27,17 +27,16 @@ with quickshell: see all thoses waarnings and errors set keybinds. for screenshot fix screenshot (copy, write, etc.) - fix battery icon fix player control icons remove unnecessary stuff - + give battery percentage maybe modify some of the images (like the notification body) do a full bar (no ugly empty space at top) add brightness slider maybe change sound icon by volume level maybe incorpore the fast fourier transform code - add some modules to see system stats + maybe write some notification center