From 08414045a56517d95e94f55c406ec8940336c6c7 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 23 Jan 2025 15:36:31 +0100 Subject: ... --- accounts/gkleen@sif/niri/default.nix | 8 ++-- accounts/gkleen@sif/systemd.nix | 84 ++++++++++++++++++------------------ 2 files changed, 47 insertions(+), 45 deletions(-) (limited to 'accounts/gkleen@sif') diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index 628a8161..2e9b6909 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix @@ -98,7 +98,7 @@ let with-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_unnamed_workspace); with_select_window = pkgs.writeShellApplication { - name = "with-unnamed-workspace"; + name = "with-select-window"; runtimeInputs = [ niri pkgs.gojq pkgs.socat config.programs.fuzzel.package pkgs.gawk ]; text = '' window_select="$1" @@ -108,9 +108,9 @@ let windows_json="$(niri msg -j windows)" active_workspace="$(jq -r '.[] | select(.is_focused) | .workspace_id' <<<"$windows_json")" - window="$(gojq -r --arg active_workspace "$active_workspace" '.[] | select('"$window_select"') | "\(.title)\t\(.id)"' <<<"$windows_json" | fuzzel --log-level=warning --dmenu)" - window_id="$(awk -F $'\t' '{print $2}' <<<"$window")" - window_json="$(jq -r --arg window_id "$window_id" '.[] | select(.id == ($window_id | tonumber))' <<<"$windows_json")" + window_ix="$(gojq -r --arg active_workspace "$active_workspace" '.[] | select('"$window_select"') | "\(.title)\u0000icon\u001f\(.app_id)"' <<<"$windows_json" | fuzzel --log-level=warning --dmenu --index)" + # shellcheck disable=SC2016 + window_json="$(gojq -rc --arg active_workspace "$active_workspace" --arg window_ix "$window_ix" 'map(select('"$window_select"')) | .[($window_ix | tonumber)]' <<<"$windows_json")" [[ -z "$window_json" ]] && exit 1 diff --git a/accounts/gkleen@sif/systemd.nix b/accounts/gkleen@sif/systemd.nix index bce2f4cd..7e83662f 100644 --- a/accounts/gkleen@sif/systemd.nix +++ b/accounts/gkleen@sif/systemd.nix @@ -207,53 +207,55 @@ in { RuntimeDirectory = "gtklock"; CacheDirectory = "gtklock"; ExecStartPre = [ - "${pkgs.libsForQt5.qt5.qttools.bin}/bin/qdbus org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.KeePassXC.MainWindow.lockAllDatabases" - "${config.systemd.package}/bin/systemctl --user stop gpg-agent.service" - (pkgs.writeShellScript "generate-css" '' - set -x - export PATH="${lib.makeBinPath [cfg.programs.wpaperd.package pkgs.jq pkgs.coreutils pkgs.imagemagick pkgs.findutils]}:$PATH" + "${lib.getExe' pkgs.libsForQt5.qt5.qttools.bin "qdbus"} org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.KeePassXC.MainWindow.lockAllDatabases" + "${lib.getExe' config.systemd.package "systemctl"} --user stop gpg-agent.service" + "${lib.getExe pkgs.playerctl} -a pause" + (lib.getExe (pkgs.writeShellApplication { + name = "generate-css"; + runtimeInputs = with pkgs; [cfg.programs.wpaperd.package jq coreutils imagemagick findutils]; + text = '' + declare -A monitors + monitors=() + while IFS= read -r entry; do + path=$(jq -r ".path" <<<"$entry") + [[ -z "$path" || ! -f "$path" ]] && continue + blurred_path="$CACHE_DIRECTORY"/"$(b2sum -l 128 <<<"$path" | cut -d' ' -f1)"."''${path##*.}" + monitor=$(jq -r ".display" <<<"$entry") + if [[ ! -f "$blurred_path" ]]; then + mkdir -p "$(dirname "$blurred_path")" + magick "$path" -filter Gaussian -resize 6.25% -define filter:sigma=2.5 -resize 1600% "$blurred_path" & + fi + monitors+=([$monitor]="$blurred_path") + done < <(wpaperctl all-wallpapers -j | jq -c ".[]") + # wait - declare -A monitors - monitors=() - while IFS= read -r entry; do - path=$(jq -r ".path" <<<"$entry") - [[ -z "$path" || ! -f "$path" ]] && continue - blurred_path="$CACHE_DIRECTORY"/"$(b2sum -l 128 <<<"$path" | cut -d' ' -f1)"."''${path##*.}" - monitor=$(jq -r ".display" <<<"$entry") - if [[ ! -f "$blurred_path" ]]; then - mkdir -p "$(dirname "$blurred_path")" - magick "$path" -filter Gaussian -resize 6.25% -define filter:sigma=2.5 -resize 1600% "$blurred_path" & - fi - monitors+=([$monitor]="$blurred_path") - done < <(wpaperctl all-wallpapers -j | jq -c ".[]") - # wait - - cp --no-preserve=mode ${pkgs.writeText "gtklock.css" '' - #window-box { - padding: 64px; - /* border: 1px solid black; */ - border-radius: 4px; - box-shadow: rgba(0, 0, 0, 0.8) 0px 4px 12px; - /* background-color: white; */ - background-color: rgba(0, 0, 0, 0.5); + cp --no-preserve=mode ${pkgs.writeText "gtklock.css" '' + #window-box { + padding: 64px; + /* border: 1px solid black; */ + border-radius: 4px; + box-shadow: rgba(0, 0, 0, 0.8) 0px 4px 12px; + /* background-color: white; */ + background-color: rgba(0, 0, 0, 0.5); + } + ''} "$RUNTIME_DIRECTORY"/style.css + for monitor in "''${!monitors[@]}"; do + cat >>"$RUNTIME_DIRECTORY"/style.css <>"$RUNTIME_DIRECTORY"/style.css <