From 60410692dcf5a9850f1a20042cafdb9da12bffc8 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 11 Oct 2022 19:11:34 +0200 Subject: [PATCH] Use notify-send from nix within scripts Also adjust dmenu selection to follow my naming conventions. Ensure other dependencies are provided via nix. --- home/modules/programs/khal.nix | 4 +--- .../packages/custom/dmenu-scripts/default.nix | 21 ++++++++----------- home/packages/custom/dmenu-scripts/system.sh | 2 +- home/windowManager/i3.nix | 12 +++++------ home/xsession.nix | 2 +- shells/reuter/monorepo.nix | 2 +- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/home/modules/programs/khal.nix b/home/modules/programs/khal.nix index 3339ba1..82b2b55 100644 --- a/home/modules/programs/khal.nix +++ b/home/modules/programs/khal.nix @@ -5,8 +5,6 @@ with lib; let cfg = config.programs.khal; - # TODO: Make more compatible, e.g. provide notify from outside and add checks whether to use or not. - # Maybe create small php script instead which parses the khal output and checks for beginning notificationScript = pkgs.writeShellApplication { name = "khal-notification"; text = '' @@ -16,7 +14,7 @@ let exit 0; fi - notify-send \ + ${pkgs.libnotify}/bin/notify-send \ --urgency=critical \ --expire-time=90000 \ --icon="${config.gtk.iconTheme.package}/share/icons/${config.gtk.iconTheme.name}/32/apps/office-calendar.svg" \ diff --git a/home/packages/custom/dmenu-scripts/default.nix b/home/packages/custom/dmenu-scripts/default.nix index 898ecc9..6086689 100644 --- a/home/packages/custom/dmenu-scripts/default.nix +++ b/home/packages/custom/dmenu-scripts/default.nix @@ -2,20 +2,15 @@ writeShellApplication, dmenu, dunst, + libnotify, bc, - firefox, - i3 + i3, + xdg-utils }: let - # Still has many references to Ubuntu system tools. - # Will migrate step by step and update references. - - # For now it is cool to have a first custom package which can be installed. - - # It already uses nix dunst and dmenu. - # Also things like version switch should not be necessary once I managed nix shells. + # Things like version switch should not be necessary once I managed nix shells. dmenu-custom-scripts-calc = writeShellApplication { name = "dmenu-custom-scripts-calc"; @@ -73,12 +68,12 @@ let runtimeInputs = [ dmenu - firefox + xdg-utils ]; text = '' file=$(find ~/Projects/docs/php/ -maxdepth 1 -name '*.html' -printf "%f\n" | dmenu -i -l 20 -p "Search Term") - firefox --new-tab "http://php.docs.localhost/$file" + xdg-open "http://php.docs.localhost/$file" ''; }; @@ -87,6 +82,7 @@ let runtimeInputs = [ dmenu + libnotify ]; text = '' @@ -102,6 +98,7 @@ let runtimeInputs = [ dmenu + libnotify ]; text = builtins.readFile ./xdebug.sh; @@ -109,7 +106,7 @@ let in writeShellApplication { - name = "dmenu_selection"; + name = "custom-dmenu-selection"; # TODO: Find way to remove the nix prefixes from "files" text = '' diff --git a/home/packages/custom/dmenu-scripts/system.sh b/home/packages/custom/dmenu-scripts/system.sh index 893fa14..838d49e 100644 --- a/home/packages/custom/dmenu-scripts/system.sh +++ b/home/packages/custom/dmenu-scripts/system.sh @@ -22,7 +22,7 @@ case "$chosen" in "logout") i3-msg exit ;; -# Not supported, seems to complicated and not recommended with ssh +# Not supported, seems to complicated and not recommended with # "hibernate") # pkill -u "$USER" -USR1 dunst # i3lock -c '#2E3436' diff --git a/home/windowManager/i3.nix b/home/windowManager/i3.nix index 2e36da0..9621ab6 100644 --- a/home/windowManager/i3.nix +++ b/home/windowManager/i3.nix @@ -1,4 +1,4 @@ -{ config }: +{ config, pkgs }: let modifier = config.xsession.windowManager.i3.config.modifier; @@ -216,7 +216,7 @@ in { # For docs, see: https://developer.gnome.org/integration-guide/stable/desktop-files.html.en "${modifier}+a" = "exec --no-startup-id i3-dmenu-desktop"; - "${modifier}+space" = "exec --no-startup-id dmenu_selection"; + "${modifier}+space" = "exec --no-startup-id custom-dmenu-selection"; # change focus "${modifier}+h" = "focus left"; @@ -317,10 +317,10 @@ in { # ~ > pacmd move-sink-input 3 8 # Function Key Bindings (💡) - "XF86MonBrightnessUp" = "exec xbacklight -inc 10 && notify-send \"Changed Display Brightness\" \"Now: $(xbacklight)\""; - "XF86MonBrightnessDown" = "exec xbacklight -dec 10 && notify-send \"Changed Display Brightness\" \"Now: $(xbacklight)\""; - "Shift+XF86MonBrightnessUp" = "exec xbacklight -inc 1 && notify-send \"Changed Display Brightness\" \"Now: $(xbacklight)\""; - "Shift+XF86MonBrightnessDown" = "exec xbacklight -dec 1 && notify-send \"Changed Display Brightness\" \"Now: $(xbacklight)\""; + "XF86MonBrightnessUp" = "exec xbacklight -inc 10 && ${pkgs.libnotify}/bin/notify-send \"Changed Display Brightness\" \"Now: $(xbacklight)\""; + "XF86MonBrightnessDown" = "exec xbacklight -dec 10 && ${pkgs.libnotify}/bin/notify-send \"Changed Display Brightness\" \"Now: $(xbacklight)\""; + "Shift+XF86MonBrightnessUp" = "exec xbacklight -inc 1 && ${pkgs.libnotify}/bin/notify-send \"Changed Display Brightness\" \"Now: $(xbacklight)\""; + "Shift+XF86MonBrightnessDown" = "exec xbacklight -dec 1 && ${pkgs.libnotify}/bin/notify-send \"Changed Display Brightness\" \"Now: $(xbacklight)\""; # Dunst Key Bindings # See: man dunstctl.1 diff --git a/home/xsession.nix b/home/xsession.nix index dde370a..e5ef350 100644 --- a/home/xsession.nix +++ b/home/xsession.nix @@ -29,6 +29,6 @@ ''; windowManager.i3 = import ./windowManager/i3.nix { - inherit config; + inherit config pkgs; }; } diff --git a/shells/reuter/monorepo.nix b/shells/reuter/monorepo.nix index b1eace0..7b4a584 100644 --- a/shells/reuter/monorepo.nix +++ b/shells/reuter/monorepo.nix @@ -16,7 +16,7 @@ let name = "project-frontend-compile"; text = '' yarn run build - notify-send "done compiling frontend" + ${pkgs.libnotify}/bin/notify-send "done compiling frontend" ''; };