From 26310712218e10d956ac226bf1197667e0064bd9 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Wed, 31 May 2023 05:06:51 +0200 Subject: [PATCH] Keybind to toggle wlsunset (with notifications!) --- home/features/wayland/hyprland/hyprland.conf | 7 ++++--- home/features/wayland/wlsunset.nix | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/home/features/wayland/hyprland/hyprland.conf b/home/features/wayland/hyprland/hyprland.conf index c4839ca..bba7690 100644 --- a/home/features/wayland/hyprland/hyprland.conf +++ b/home/features/wayland/hyprland/hyprland.conf @@ -32,7 +32,7 @@ gestures { } # Execute apps at launch -exec-once = NO_TMUX=1 wezterm & firefox & discord +exec-once = wezterm & firefox & discord # {{{ Window rules # {{{ Automatically move stuff to workspaces @@ -51,17 +51,18 @@ windowrulev2 = idleinhibit focus, class:^(firefox)$, title:^(.*YouTube.*)$ # {{{ Keybinds $mod = SUPER -#u {{{ General +# {{{ General bind = $mod, C, killactive, # Kill current bind = $mod, F, fullscreen, # Fullscreen # Execute external things -bind = $mod, return, exec, NO_TMUX=1 wezterm # Launch wezterm +bind = $mod, return, exec, wezterm # Launch wezterm bind = $mod, T, exec, wl-ocr # Use ocr script bind = $mod SHIFT, T, exec, hyprpicker | wl-copy && libnotify "Copied color $(wp-paste)" # Color picker bind = $mod, Q, exec, wlogout # Show logout menu bind = $mod, L, exec, loginctl lock-session # Lock screen bind = $mod, P, exec, wofi --show drun # Launch app +bind = $mod, B, exec, wlsunset-toggle # Toggle blue light filter thingy # Work with the special workspace bind = $mod, x, togglespecialworkspace, diff --git a/home/features/wayland/wlsunset.nix b/home/features/wayland/wlsunset.nix index 73bc326..a8853a7 100644 --- a/home/features/wayland/wlsunset.nix +++ b/home/features/wayland/wlsunset.nix @@ -1,3 +1,18 @@ +{ pkgs, lib, ... }: +let + libnotify = lib.getExe pkgs.libnotify; + + wlsunset-toggle = pkgs.writeShellScriptBin "wlsunset-toggle" '' + if [ "active" = "$(systemctl --user is-active wlsunset.service)" ] + then + systemctl --user stop wlsunset.service + ${libnotify} "Stopped wlsunset" + else + systemctl --user start wlsunset.service + ${libnotify} "Started wlsunset" + fi + ''; +in { services.wlsunset = { enable = true; @@ -6,4 +21,6 @@ latitude = "53.2"; longitude = "6.5"; }; + + home.packages = [ wlsunset-toggle ]; }