diff --git a/home/common/optional/desktop/common/default.nix b/home/common/optional/desktop/common/default.nix index 87dced6..bb5bddc 100644 --- a/home/common/optional/desktop/common/default.nix +++ b/home/common/optional/desktop/common/default.nix @@ -21,5 +21,6 @@ pkgs.pandoc pkgs.texlive.combined.scheme-small pkgs.libreoffice + pkgs.set_wm_class ]; } diff --git a/home/common/optional/desktop/dwm/default.nix b/home/common/optional/desktop/dwm/default.nix index eb87bf8..cca4af7 100644 --- a/home/common/optional/desktop/dwm/default.nix +++ b/home/common/optional/desktop/dwm/default.nix @@ -31,6 +31,7 @@ ./scripts/aichat-wrapper.nix ./scripts/dmenu-wifi.nix ./scripts/battery-status.nix + ./scripts/dmenu-set-wm-class.nix ]; home.packages = [ diff --git a/home/common/optional/desktop/dwm/scripts/dmenu-set-wm-class.nix b/home/common/optional/desktop/dwm/scripts/dmenu-set-wm-class.nix new file mode 100644 index 0000000..a155136 --- /dev/null +++ b/home/common/optional/desktop/dwm/scripts/dmenu-set-wm-class.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: +{ + home.packages = with pkgs; [ + (writeShellScriptBin "dmenu-set-wm-class" '' + ${libnotify}/bin/notify-send "Set Window Class" "Select window..." + winid=$(${xorg.xwininfo}/bin/xwininfo | grep "Window id:" | grep -o "0x[0-9a-fA-F]*") + class=$(${xorg.xprop}/bin/xprop -id "$winid" WM_CLASS | grep -o "\".*\"$") + new_class=$( echo "" | ${dmenu}/bin/dmenu -p "Selected: $class. Set class name of window:") + [ -z "$new_class" ] && ${libnotify}/bin/notify-send "Set Window Class" "Nothing set, exiting" && exit + ${set_wm_class}/bin/set_wm_class "$winid" "$new_class" + '') + ]; +} diff --git a/home/common/optional/desktop/dwm/sxhkdrc.nix b/home/common/optional/desktop/dwm/sxhkdrc.nix index 10e3910..9995a81 100644 --- a/home/common/optional/desktop/dwm/sxhkdrc.nix +++ b/home/common/optional/desktop/dwm/sxhkdrc.nix @@ -26,6 +26,9 @@ control + F7 emoji-picker + + control + F4 + dmenu-set-wm-class ''; }; } diff --git a/hosts/common/optional/dwm.nix b/hosts/common/optional/dwm.nix index e6eda05..74fb98e 100644 --- a/hosts/common/optional/dwm.nix +++ b/hosts/common/optional/dwm.nix @@ -13,11 +13,11 @@ enable = true; package = pkgs.dwm.overrideAttrs { #src = /home/sam/.local/share/src/dwm; - src = pkgs.fetchgit { - url = "https://git.bitlab21.com/sam/dwm"; - rev = "49dd30c0d9970ce480ada51dfcaac1a071804c64"; - sha256 = "0ywca25a1pdjvb4cgv5gx36x3yd6922pqvn9a5f60lcn5fv2a96n"; - }; + src = pkgs.fetchgit { + url = "https://git.bitlab21.com/sam/dwm"; + rev = "c8fb47e28bb134cf08c74801c350cc478635679a"; + sha256 = "sha256-UiznF1FIt72lF8gP5WAnrleSnJJSFJKnZMhwk1HiEmQ"; + }; }; }; }; diff --git a/pkgs/default.nix b/pkgs/default.nix index d361fc5..4547dbf 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -6,4 +6,5 @@ pkgs: { nsxiv = pkgs.callPackage ./nsxiv {}; sqlfmt = pkgs.callPackage ./sqlfmt {}; kunst = pkgs.callPackage ./kunst {}; + set_wm_class = pkgs.callPackage ./set_wm_class {}; } diff --git a/pkgs/set_wm_class/default.nix b/pkgs/set_wm_class/default.nix new file mode 100644 index 0000000..6e7c630 --- /dev/null +++ b/pkgs/set_wm_class/default.nix @@ -0,0 +1,35 @@ +{ pkgs ? import { } +, fetchFromGitea ? pkgs.fetchFromGitea +, pkg-config ? pkgs.pkg-config +, libX11 ? pkgs.xorg.libX11 +}: +pkgs.stdenv.mkDerivation { + pname = "set_wm_class"; + name = "set_wm_class"; + + src = fetchFromGitea { + domain = "git.bitlab21.com"; + owner = "sam"; + repo = "set_wm_class"; + rev = "b39fb4b360"; + sha256 = "sha256-5z2YQof4jbfa1dQll5GLt2OL54UhDKZ4Dzzte7vT0zM="; + }; + + nativeBuildInputs = [ + pkg-config + ]; + + buildInputs = [ + libX11 + ]; + + buildPhase = '' + make + ''; + + installPhase = '' + mkdir -p $out/bin + mv set_wm_class $out/bin + ''; + +}