From a3d777256e5f9733c46cdfe0179946e0487e3276 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Tue, 20 Aug 2024 20:24:43 +0300 Subject: [PATCH] Waybar : Add temperature. --- config/Setting.nix | 107 ++++++------------------- home/config/dconf/Key.nix | 10 +-- home/config/fuzzel/default.nix | 2 +- home/config/keyd/module/DRG.nix | 4 +- home/config/keyd/module/Jetbrains.nix | 4 +- home/config/mako/default.nix | 2 +- home/config/sway/module/Brightness.nix | 2 +- home/config/sway/module/Input.nix | 2 +- home/config/sway/module/Sound.nix | 6 +- home/config/sway/module/System.nix | 4 +- home/config/sway/module/Terminal.nix | 4 +- home/config/top/btop/default.nix | 2 +- home/config/waybar/config/default.nix | 15 ++-- home/config/yazi/module/Yazi.nix | 2 +- host/dasha/default.nix | 10 ++- host/desktop/default.nix | 7 ++ host/home/default.nix | 7 ++ host/work/default.nix | 7 ++ module/Keyd.nix | 2 +- 19 files changed, 86 insertions(+), 113 deletions(-) diff --git a/config/Setting.nix b/config/Setting.nix index 7db1c04..fb0ea7f 100644 --- a/config/Setting.nix +++ b/config/Setting.nix @@ -17,44 +17,12 @@ }; }; - # Default browser settings. - browser = mkOption { - default = { }; - type = types.submodule { - options = { - bin = mkOption { - default = "firefox-esr"; - type = types.str; - }; - }; - }; - }; - - # Terminal settings. - terminal = mkOption { - default = { }; - type = types.submodule { - options = { - bin = mkOption { - default = "foot"; - type = types.str; - }; - }; - }; - }; - # Whether to use Dpi-aware setting in supported apps. dpiAware = mkOption { default = false; type = types.bool; }; - # The key used for system-related shortcuts. - sysctrl = mkOption { - default = "print"; - type = types.str; - }; - # Keyboard options. keyboard = mkOption { default = { }; @@ -72,57 +40,6 @@ }; }; - # Settings related to different refreshes, like top apps. - refresh = mkOption { - default = { }; - type = types.submodule { - options = { - top = mkOption { - default = 2000; - type = types.int; - }; - }; - }; - }; - - # Configure steps for different actions. - step = mkOption { - default = { }; - type = types.submodule { - options = { - brightness = mkOption { - default = 5; - type = types.int; - }; - volume = mkOption { - default = 5; - type = types.int; - }; - media = mkOption { - default = 10; - type = types.int; - }; - }; - }; - }; - - # Specify timeouts. - timeout = mkOption { - default = { }; - type = types.submodule { - options = { - popup = mkOption { - default = 5000; - type = types.int; - }; - keyd = mkOption { - default = 150; - type = types.int; - }; - }; - }; - }; - # Zapret params. zapret = mkOption { default = {}; @@ -135,5 +52,29 @@ }; }; }; + + # CPU configurations. + cpu = mkOption { + default = {}; + type = types.submodule { + options = { + hwmon = mkOption { + default = {}; + type = types.submodule { + options = { + path = mkOption { + default = ""; + type = types.str; + }; + file = mkOption { + default = ""; + type = types.str; + }; + }; + }; + }; + }; + }; + }; }; } diff --git a/home/config/dconf/Key.nix b/home/config/dconf/Key.nix index 95211e9..86af119 100644 --- a/home/config/dconf/Key.nix +++ b/home/config/dconf/Key.nix @@ -82,31 +82,31 @@ in { }; "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1" = { - binding = "${config.setting.sysctrl}z"; + binding = "printz"; command = "systemctl suspend -i"; name = "System Sleep"; }; "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2" = { - binding = "${config.setting.sysctrl}x"; + binding = "printx"; command = "systemctl poweroff -i"; name = "System Poweroff"; }; "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3" = { - binding = "${config.setting.sysctrl}c"; + binding = "printc"; command = "systemctl reboot -i"; name = "System Reboot"; }; "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4" = { - binding = "${config.setting.sysctrl}p"; + binding = "printp"; command = "powersave toggle"; name = "Toggle Powersave"; }; "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom5" = { - binding = "${config.setting.sysctrl}l"; + binding = "printl"; command = "powerlimit toggle"; name = "Toggle Powerlimit"; }; diff --git a/home/config/fuzzel/default.nix b/home/config/fuzzel/default.nix index 16ddae3..6662adf 100644 --- a/home/config/fuzzel/default.nix +++ b/home/config/fuzzel/default.nix @@ -9,7 +9,7 @@ in { lines = 20; prompt = "\"\""; show-actions = "yes"; - terminal = config.setting.terminal.bin; + terminal = "foot"; width = 40; # list-executables-in-path = "no"; }; diff --git a/home/config/keyd/module/DRG.nix b/home/config/keyd/module/DRG.nix index ad6c39f..b29bc7b 100644 --- a/home/config/keyd/module/DRG.nix +++ b/home/config/keyd/module/DRG.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: { +{ pkgs, ... }: { file = (pkgs.formats.ini {}).generate "KeydDrgConfig" { steam-app-548430 = { "alt.1" = "macro(enter 10ms L e t ' s 10ms space d o 10ms space t h i s 10ms space T e x a s 10ms space s t y l e ! 10ms enter)"; @@ -26,7 +26,7 @@ "alt.w" = "macro(enter 10ms r enter)"; "alt.x" = "macro(enter 10ms > space H e r e space < enter)"; "alt.z" = "macro(enter 10ms < space L e f t enter)"; - leftshift = "timeout(leftcontrol, ${toString config.setting.timeout.keyd}, leftshift)"; + leftshift = "timeout(leftcontrol, 150, leftshift)"; }; }; } diff --git a/home/config/keyd/module/Jetbrains.nix b/home/config/keyd/module/Jetbrains.nix index 976f57f..cb4026c 100644 --- a/home/config/keyd/module/Jetbrains.nix +++ b/home/config/keyd/module/Jetbrains.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: { +{ pkgs, ... }: { file = (pkgs.formats.ini {}).generate "KeydJetbrainsConfig" { "jetbrains-*" = { "alt./" = "C-/"; @@ -16,7 +16,7 @@ "alt.q" = "A-left"; "alt.r" = "S-f10"; "alt.s" = "C-A-s"; - "alt.tab" = "timeout(f8, ${toString config.setting.timeout.keyd}, macro2(0, 0, f7))"; + "alt.tab" = "timeout(f8, 150, macro2(0, 0, f7))"; "alt.v" = "C-q"; "alt.w" = "C-S-A-t"; "alt.x" = "C-f4"; diff --git a/home/config/mako/default.nix b/home/config/mako/default.nix index 0f8f807..6ceb754 100644 --- a/home/config/mako/default.nix +++ b/home/config/mako/default.nix @@ -6,7 +6,7 @@ in { anchor = "top-center"; background-color = "#${config.style.color.bg.dark}${alpha}"; border-color = "#${config.style.color.border}${alpha}"; - default-timeout = config.setting.timeout.popup; + default-timeout = 5000; font = "${config.style.font.serif.name} ${toString config.style.font.size.popup}"; height = 120; icons = 0; diff --git a/home/config/sway/module/Brightness.nix b/home/config/sway/module/Brightness.nix index 8075aa3..88a8c56 100644 --- a/home/config/sway/module/Brightness.nix +++ b/home/config/sway/module/Brightness.nix @@ -1,5 +1,5 @@ { config, ... }: let - step = config.setting.step.brightness; + step = 5; in { text = '' bindsym XF86MonBrightnessDown exec light -U ${toString step} diff --git a/home/config/sway/module/Input.nix b/home/config/sway/module/Input.nix index 1356c62..0bb991c 100644 --- a/home/config/sway/module/Input.nix +++ b/home/config/sway/module/Input.nix @@ -38,7 +38,7 @@ } # Hide mouse cursor after a period of inactivity. - seat seat0 hide_cursor ${toString config.setting.timeout.popup} + seat seat0 hide_cursor 5000 # Per-window languages. exec swaykbdd diff --git a/home/config/sway/module/Sound.nix b/home/config/sway/module/Sound.nix index a1ade29..438a356 100644 --- a/home/config/sway/module/Sound.nix +++ b/home/config/sway/module/Sound.nix @@ -1,6 +1,6 @@ -{ config, ... }: let - step_volume = config.setting.step.volume; - step_music = config.setting.step.media; +{ ... }: let + step_volume = 5; + step_music = 10; in { text = '' bindsym --to-code XF86AudioRaiseVolume exec 'pactl set-sink-volume @DEFAULT_SINK@ +${toString step_volume}%' diff --git a/home/config/sway/module/System.nix b/home/config/sway/module/System.nix index 77f0b09..ca3df9e 100644 --- a/home/config/sway/module/System.nix +++ b/home/config/sway/module/System.nix @@ -1,5 +1,5 @@ -{ config, ... }: let - mod = config.setting.sysctrl; +{ ... }: let + mod = "print"; in { text = '' bindsym ${mod} input * xkb_switch_layout 0 diff --git a/home/config/sway/module/Terminal.nix b/home/config/sway/module/Terminal.nix index 1d8cdd6..57214ed 100644 --- a/home/config/sway/module/Terminal.nix +++ b/home/config/sway/module/Terminal.nix @@ -1,6 +1,6 @@ -{ config, ... }: { +{ ... }: { text = '' - set $term ${config.setting.terminal.bin} + set $term foot bindsym --to-code $mod+Escape exec $term -e bash -i -c "tmux new-session -A -s $USER; bash -i" ''; diff --git a/home/config/top/btop/default.nix b/home/config/top/btop/default.nix index f12d730..ceae331 100644 --- a/home/config/top/btop/default.nix +++ b/home/config/top/btop/default.nix @@ -55,7 +55,7 @@ shown_boxes = "cpu mem net proc" #* Update time in milliseconds, recommended 2000 ms or above for better sample times for graphs. - update_ms = ${toString config.setting.refresh.top} + update_ms = 2000 #* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu direct", #* "cpu lazy" sorts top process over time (easier to follow), "cpu direct" updates top process directly. diff --git a/home/config/waybar/config/default.nix b/home/config/waybar/config/default.nix index 4f4076b..ff42b26 100644 --- a/home/config/waybar/config/default.nix +++ b/home/config/waybar/config/default.nix @@ -30,7 +30,7 @@ in { "battery" "custom/powerlimit" "cpu" - # "temperature" + "temperature" "memory" "custom/powersave" "custom/display" @@ -81,7 +81,7 @@ in { on-click-right = "powerlimit toggle"; }; pulseaudio = { - scroll-step = config.setting.step.volume; + scroll-step = 5; format = "{volume}% {icon}"; format-muted = "󰸈"; format-icons = { @@ -108,26 +108,29 @@ in { cpu = { format = "{usage}% ({load})"; interval = refreshInterval; - on-click = "${config.setting.terminal.bin} -e bash -c btop"; + on-click = "foot -e bash -c btop"; on-click-right = "powersave toggle"; tooltip = false; }; memory = { format = "{percentage}%"; interval = refreshInterval; - on-click = "${config.setting.terminal.bin} -e bash -c btop"; + on-click = "foot -e bash -c btop"; on-click-right = "powersave toggle"; }; temperature = { format = "{temperatureC}°C"; + hwmon-path-abs = "${config.setting.cpu.hwmon.path}"; + input-filename = "${config.setting.cpu.hwmon.file}"; interval = refreshInterval; - on-click = "${config.setting.terminal.bin} -e bash -c btop"; + on-click = "foot -e bash -c btop"; on-click-right = "powersave toggle"; + tooltip = false; }; "custom/powersave" = { exec = "powersave waybar"; interval = refreshInterval; - on-click = "${config.setting.terminal.bin} -e bash -c btop"; + on-click = "foot -e bash -c btop"; on-click-right = "powersave toggle"; }; "custom/display" = { diff --git a/home/config/yazi/module/Yazi.nix b/home/config/yazi/module/Yazi.nix index 0533d08..4ed8744 100644 --- a/home/config/yazi/module/Yazi.nix +++ b/home/config/yazi/module/Yazi.nix @@ -30,7 +30,7 @@ browser = [{ desc = "Browser"; orphan = true; - run = openWith config.setting.browser.bin; + run = openWith "firefox-esr"; }]; text = [{ desc = "Text"; diff --git a/host/dasha/default.nix b/host/dasha/default.nix index 505fd65..43a3685 100644 --- a/host/dasha/default.nix +++ b/host/dasha/default.nix @@ -1,4 +1,4 @@ -{ lib, ... }: { +{ ... }: { imports = [ ./Filesystem.nix ]; @@ -24,4 +24,12 @@ gaming.enable = true; }; }; + + setting = { + cpu.hwmon = { + path = "/sys/devices/platform/coretemp.0/hwmon"; + file = "temp1_input"; + }; + }; + } diff --git a/host/desktop/default.nix b/host/desktop/default.nix index d317fc1..b7930dc 100644 --- a/host/desktop/default.nix +++ b/host/desktop/default.nix @@ -32,4 +32,11 @@ gaming.enable = true; }; }; + + setting = { + cpu.hwmon = { + path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon"; + file = "temp1_input"; + }; + }; } diff --git a/host/home/default.nix b/host/home/default.nix index 3260af4..0944589 100644 --- a/host/home/default.nix +++ b/host/home/default.nix @@ -33,4 +33,11 @@ desktop.enable = true; }; }; + + setting = { + cpu.hwmon = { + path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon"; + file = "temp1_input"; + }; + }; } diff --git a/host/work/default.nix b/host/work/default.nix index da3c79b..ec893e4 100644 --- a/host/work/default.nix +++ b/host/work/default.nix @@ -24,4 +24,11 @@ gaming.enable = true; }; }; + + setting = { + cpu.hwmon = { + path = "/sys/devices/platform/coretemp.0/hwmon"; + file = "temp1_input"; + }; + }; } diff --git a/module/Keyd.nix b/module/Keyd.nix index 2fc0cfb..fca74ff 100644 --- a/module/Keyd.nix +++ b/module/Keyd.nix @@ -19,7 +19,7 @@ in { backspace = "delete"; # Delete key on backspace. capslock = "overload(control, esc)"; # Ctrl/esc combo. compose = "layer(layer_number)"; # Number input layer. - esc = "${config.setting.sysctrl}"; # System controls. + esc = "print"; # System controls. leftcontrol = "overload(layer_alternative, leftcontrol)"; # Alternative layer for home, end etc. rightcontrol = "layer(layer_control)"; # Media and other controls. rightshift = "backspace"; # Backspace.