From cf5bc09e33d811dbd8b8798b4311054aaa5fa3d4 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 13 Aug 2024 23:02:30 +0200 Subject: ... --- accounts/gkleen@sif/default.nix | 8 +++++++- accounts/gkleen@sif/hyprland.nix | 39 +++++++++++++++++++++++++++++++++++++-- accounts/gkleen@sif/systemd.nix | 1 + 3 files changed, 45 insertions(+), 3 deletions(-) (limited to 'accounts') diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index d1a0ec3f..2c6d747d 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix @@ -933,7 +933,13 @@ in { "gtklock/config.ini" = { source = (pkgs.formats.ini {}).generate "config.ini" { main = { - + }; + }; + }; + "qalculate/qalc.cfg" = { + source = (pkgs.formats.ini {}).generate "qalc.cfg" { + General = { + dot_as_separator = 0; }; }; }; diff --git a/accounts/gkleen@sif/hyprland.nix b/accounts/gkleen@sif/hyprland.nix index 252b8351..d26b72a7 100644 --- a/accounts/gkleen@sif/hyprland.nix +++ b/accounts/gkleen@sif/hyprland.nix @@ -1,5 +1,7 @@ -{ pkgs, lib, ... }: -{ +{ pkgs, lib, config, userName, ... }: +let + cfg = config.home-manager.users.${userName}; +in { monitor = [ ",preferred,auto,auto" "eDP-1,3840x2160@59.99900,auto,1.5" @@ -217,6 +219,39 @@ makeWrapper ${lib.getExe pkgs.hyprpicker} $out \ --prefix PATH : ${lib.makeBinPath [pkgs.wl-clipboard-rs]} ''} -a" + "$mainMod, E, exec, ${pkgs.writeShellScript "qalc-fuzzel" '' + export PATH="${lib.makeBinPath (with pkgs; [ wl-clipboard-rs libqalculate cfg.programs.fuzzel.package coreutils findutils libnotify gnugrep ])}:$PATH" + + RESULTS_DIR="$HOME/.cache/qalc-fuzzel" + prev() { + FOUND=false + while IFS= read -r line; do + [[ -n "$line" ]] || continue + FOUND=true + echo $line + done < <(export LC_ALL=C.UTF-8; echo; find "$RESULTS_DIR" -type f -printf $'%T@ %p\n' | sort -n | cut -d' ' -f2- | xargs -r cat) + $FOUND || echo + } + FUZZEL_RES=$(prev | fuzzel --dmenu --prompt "qalc> ") || exit $? + if [[ "$FUZZEL_RES" =~ .*\ =\ .* ]]; then + QALC_RES="$FUZZEL_RES" + QALC_RET=0 + else + QALC_RES=$(qalc "$FUZZEL_RES" 2>&1) + QALC_RET=$? + fi + [[ -n "$QALC_RES" ]] || exit 1 + EXISTING=false + fgrep -xrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch + [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true + if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then + RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' "$RES_FILE" <<<"$QALC_RES" + fi + [[ "$QALC_RES" =~ .*\ =\ (.*) ]] && QALC_RES="''${BASH_REMATCH[1]}" + [[ $QALC_RET -eq 0 ]] && wl-copy "$QALC_RES" + notify-send "$QALC_RES" + ''}" "$mainMod CTRL, return, togglespecialworkspace, term" "$mainMod CTRL, e, togglespecialworkspace, edit" diff --git a/accounts/gkleen@sif/systemd.nix b/accounts/gkleen@sif/systemd.nix index e5d1681c..5902946c 100644 --- a/accounts/gkleen@sif/systemd.nix +++ b/accounts/gkleen@sif/systemd.nix @@ -44,6 +44,7 @@ let in { tmpfiles.rules = [ "e /home/gkleen/screenshots - - - 365d -" + "d /home/gkleen/.cache/qalc-fuzzel - - - 1d -" ]; services = { -- cgit v1.2.3