From 43c9825e49d25fbd2c19abcdeb8f73aee8be2a4c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 14 May 2025 10:50:27 +0200 Subject: ... --- accounts/gkleen@sif/default.nix | 31 +++++++------- accounts/gkleen@sif/niri/default.nix | 14 +++---- accounts/gkleen@sif/niri/mako.nix | 54 +++++++++++------------- accounts/gkleen@sif/systemd.nix | 32 +++++++-------- accounts/gkleen@sif/zshrc | 80 +++++++++++++++++++----------------- 5 files changed, 104 insertions(+), 107 deletions(-) (limited to 'accounts/gkleen@sif') diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index b46d021e..80f03e49 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix @@ -63,7 +63,7 @@ let }; in { imports = with flake.nixosModules.userProfiles.${userName}; [ - mpv yt-dlp (args: import ./xcompose.nix (inputs // args)) + zsh tmux mpv yt-dlp (args: import ./xcompose.nix (inputs // args)) ]; config = { @@ -77,10 +77,10 @@ in { home.stateVersion = "20.09"; - nixpkgs.config = { - allowUnfree = true; - zathura.useMupdf = false; - }; + # nixpkgs.config = { + # allowUnfree = true; + # zathura.useMupdf = false; + # }; nix.registry = { "flk" = { @@ -186,7 +186,7 @@ in { gpu-api = "vulkan"; }; - zsh.initExtra = let + zsh.initContent = let zshrc = pkgs.resholve.mkDerivation { pname = "zshrc"; version = "0.0.0"; @@ -219,7 +219,6 @@ in { gnutar cpio magic-wormhole - quickserve cfg.programs.zsh.package fuse util-linux @@ -232,6 +231,7 @@ in { config.systemd.package config.programs.ssh.package gnused + miniserve ]; execer = with pkgs; [ "cannot:${lib.getExe' rpm "rpm2cpio"}" @@ -240,7 +240,6 @@ in { "cannot:${lib.getExe cfg.programs.git.package}" "cannot:${lib.getExe cpio}" "cannot:${lib.getExe' magic-wormhole "wormhole"}" - "cannot:${lib.getExe quickserve}" "cannot:${lib.getExe' fuse "fusermount"}" "cannot:${lib.getExe less}" "cannot:${lib.getExe' config.systemd.package "systemctl"}" @@ -322,14 +321,6 @@ in { "kitty_mod+m" = "detach_window ask"; }; }; - wpaperd = { - enable = true; - settings.default = { - path = "~/.wallpapers"; - duration = "15m"; - mode = "center"; - }; - }; fuzzel = { enable = true; settings = { @@ -360,6 +351,14 @@ in { }; services = { + wpaperd = { + enable = true; + settings.default = { + path = "~/.wallpapers"; + duration = "15m"; + mode = "center"; + }; + }; emacs = { enable = true; socketActivation.enable = true; diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index 732e3c7a..a9b4b0f8 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix @@ -249,7 +249,7 @@ in { import os import socket import json - import sys + # import sys from collections import defaultdict from threading import Thread, Lock from socketserver import StreamRequestHandler, ThreadingTCPServer @@ -275,7 +275,7 @@ in { def focus_workspace(output, workspace): with history_lock: workspace_history[output] = [workspace] + [ws for ws in workspace_history[output] if ws != workspace] # noqa: E501 - print(json.dumps(workspace_history), file=sys.stderr) + # print(json.dumps(workspace_history), file=sys.stderr) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.connect(os.environ["NIRI_SOCKET"]) @@ -743,19 +743,19 @@ in { "Mod+Shift+Control+C".action = move-workspace-up; "Mod+ParenLeft".action = focus-workspace "comm"; - "Mod+Shift+ParenLeft".action = move-column-to-workspace "comm"; + "Mod+Shift+ParenLeft".action = kdl.magic-leaf "move-column-to-workspace" "comm"; "Mod+ParenRight".action = focus-workspace "web"; - "Mod+Shift+ParenRight".action = move-column-to-workspace "web"; + "Mod+Shift+ParenRight".action = kdl.magic-leaf "move-column-to-workspace" "web"; "Mod+BraceRight".action = focus-workspace "read"; - "Mod+Shift+BraceRight".action = move-column-to-workspace "read"; + "Mod+Shift+BraceRight".action = kdl.magic-leaf "move-column-to-workspace" "read"; "Mod+BraceLeft".action = focus-workspace "mon"; - "Mod+Shift+BraceLeft".action = move-column-to-workspace "mon"; + "Mod+Shift+BraceLeft".action = kdl.magic-leaf "move-column-to-workspace" "mon"; "Mod+Asterisk".action = focus-workspace "vid"; - "Mod+Shift+Asterisk".action = move-column-to-workspace "vid"; + "Mod+Shift+Asterisk".action = kdl.magic-leaf "move-column-to-workspace" "vid"; "Mod+Plus".action = with-unnamed-workspace-action ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; "Mod+Shift+Plus".action = with-unnamed-workspace-action ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}''; diff --git a/accounts/gkleen@sif/niri/mako.nix b/accounts/gkleen@sif/niri/mako.nix index 2788fb82..9373dc21 100644 --- a/accounts/gkleen@sif/niri/mako.nix +++ b/accounts/gkleen@sif/niri/mako.nix @@ -3,37 +3,29 @@ config = { services.mako = { enable = true; - font = "Fira Sans 10"; - format = "%s\\n%b"; - margin = "2"; - maxVisible = -1; - backgroundColor = "#000000dd"; - progressColor = "source #223544ff"; - width = 384; - extraConfig = '' - outer-margin=1 - max-history=100 - max-icon-size=48 - - [grouped] - format=(%g) %s\n%b - - [urgency=low] - text-color=#999999ff - - [urgency=critical] - background-color=#900000dd - - [app-name=Element] - group-by=summary - - [app-name=poweralertd] - ignore-timeout=1 - default-timeout=2000 - - [mode=silent] - invisible=1 - ''; + settings = { + font = "Fira Sans 10"; + format = "%s\\n%b"; + margin = "2"; + max-visible = -1; + background-color = "#000000dd"; + progress-color = "source #223544ff"; + width = 384; + outer-margin = 1; + max-history = 100; + max-icon-size = 48; + }; + criteria = { + grouped.format = "(%g) %s\n%b"; + "urgency=low".text-color = "#999999ff"; + "urgency=critical".background-color = "#900000dd"; + "app-name=Element".group-by = "summary"; + "app-name=poweralertd" = { + ignore-timeout = true; + default-timeout = 2000; + }; + "mode=silent".invisible = true; + }; package = pkgs.symlinkJoin { name = "${pkgs.mako.name}-wrapped"; paths = with pkgs; [ mako ]; diff --git a/accounts/gkleen@sif/systemd.nix b/accounts/gkleen@sif/systemd.nix index 2237b708..90cccc58 100644 --- a/accounts/gkleen@sif/systemd.nix +++ b/accounts/gkleen@sif/systemd.nix @@ -242,7 +242,7 @@ in { "-${lib.getExe pkgs.playerctl} -a pause" "-${lib.getExe (pkgs.writeShellApplication { name = "generate-css"; - runtimeInputs = with pkgs; [cfg.programs.wpaperd.package jq coreutils imagemagick findutils]; + runtimeInputs = with pkgs; [cfg.services.wpaperd.package jq coreutils imagemagick findutils]; text = '' declare -A monitors monitors=() @@ -333,21 +333,21 @@ in { ExecStopPost = "${pkgs.coreutils}/bin/rm -rfv \"$CACHE_DIRECTORY\""; }; }; - wpaperd = { - Install = { - WantedBy = ["graphical-session.target"]; - }; - Unit = { - After = [ "graphical-session.target" ]; - PartOf = [ "graphical-session.target" ]; - }; - Service = { - ExecStart = lib.getExe cfg.programs.wpaperd.package; - Type = "simple"; - Restart = "always"; - RestartSec = "2s"; - }; - }; + # wpaperd = { + # Install = { + # WantedBy = ["graphical-session.target"]; + # }; + # Unit = { + # After = [ "graphical-session.target" ]; + # PartOf = [ "graphical-session.target" ]; + # }; + # Service = { + # ExecStart = lib.getExe cfg.services.wpaperd.package; + # Type = "simple"; + # Restart = "always"; + # RestartSec = "2s"; + # }; + # }; xembed-sni-proxy = { Unit = { PartOf = lib.mkForce ["tray.target"]; diff --git a/accounts/gkleen@sif/zshrc b/accounts/gkleen@sif/zshrc index 06f6f6f2..7645e0fc 100644 --- a/accounts/gkleen@sif/zshrc +++ b/accounts/gkleen@sif/zshrc @@ -6,11 +6,10 @@ dir() { forceShell=false wormhole=false gitWorktree="" - # notmuchMsg="" - quickserve=false modifyPDF="" + miniserve=false - while getopts ':t:a:d:ir:wqg:p:' arg; do + while getopts ':t:a:d:ir:wg:p:m' arg; do case $arg in "t") ;; "a") @@ -26,9 +25,8 @@ dir() { "r") repoUrl=${OPTARG} ;; "w") wormhole=true ;; "g") gitWorktree=${OPTARG} ;; - # "n") notmuchMsg=${OPTARG} ;; - "q") quickserve=true ;; "p") modifyPDF=${OPTARG:a} ;; + "m") miniserve=true ;; *) printf "Invalid option: %s\n" $arg >&2; exit 2 ;; esac done @@ -52,17 +50,29 @@ dir() { gitWorktree="" fi + miniservePIDFile="" + if [[ ${miniserve} = "true" ]]; then + miniservePIDFile=$(mktemp --tmpdir --suffix=.pid) + fi + cleanup() { - cd ${modifyPDF:h} if [[ -n ${modifyPDF} ]]; then + cd ${modifyPDF:h} typeset -a pages eval 'pages=(${dir}/${modifyPDF:t:r}_*.png(on))' magick -verbose "$pages" ${modifyPDF} + modifyPDF="" + fi + if [[ -n ${miniservePIDFile} ]]; then + kill --verbose $(cat ${miniservePIDFile}) && wait $(cat ${miniservePIDFile}) + miniservePIDFile="" fi } ( + set -o localtraps + trap 'return 1' INT TERM trap cleanup EXIT cd ${dir} @@ -135,18 +145,18 @@ dir() { [[ $wormhole = "true" ]] && wormhole receive --accept-file - if [[ $quickserve = "true" ]]; then - quickserve --root . --upload . --show-hidden --tar gz + if [[ ${#@} -gt 0 ]]; then + ${@} fi + cd $(pwd) # Needed for mounting to work - if [[ ${#@} -eq 0 ]] || [[ $forceShell = "true" ]]; then - if [[ ${#@} -gt 0 ]]; then - ${@} - fi - - cd $(pwd) # Needed for mounting to work + if [[ ${miniserve} = "true" ]]; then + miniserve --random-route --hidden --enable-tar-gz --enable-zip . & + echo $! > "${miniservePIDFile}" + fi + if [[ ${#@} -eq 0 ]] && [[ ${miniserve} != "true" ]] || [[ $forceShell = "true" ]]; then isSingleDir() { typeset -a contents contents=(*(N) .*(N)) @@ -160,10 +170,9 @@ dir() { } while d=$(isSingleDir); do cd ${d}; done - zsh - else - ${@} + elif [[ ${miniserve} == "true" ]]; then + wait $(cat "${miniservePIDFile}") fi ) } @@ -171,27 +180,30 @@ dir() { tmpdir() { cleanup() { - cd / + cd / unmount() { printf "Unmounting %s\n" ${1} >&2 fusermount -u ${1} || umount ${1} || sudo umount ${1} } - if mountpoint -q -- ${dir}; then - unmount ${dir} || return $? - else - while read -d $'\0' subDir; do - mountpoint -q -- ${subDir} || continue - unmount ${subDir} || return $? - done <<<$(find ${dir} -xdev -type d -print0 | sort -zr) - fi - - rm -rfv --one-file-system -- ${dir} + if [[ -n ${dir} ]]; then + if mountpoint -q -- ${dir}; then + unmount ${dir} || return $? + else + while read -d $'\0' subDir; do + mountpoint -q -- ${subDir} || continue + unmount ${subDir} || return $? + done <<<$(find ${dir} -xdev -type d -print0 | sort -zr) + fi + + rm -rfv --one-file-system -- ${dir} + dir="" + fi } local tmpdir="" - while getopts ':t:a:s:Sd:ir:wqg:p:' arg; do + while getopts ':t:a:d:ir:wg:p:m' arg; do case $arg in "t") tmpdir="=${OPTARG}" ;; "?"|":") printf "Invalid option: %s\n" $arg >&2; exit 2 ;; @@ -199,6 +211,8 @@ tmpdir() { done ( + set -o localtraps + trap 'return 1' INT TERM trap cleanup EXIT @@ -247,14 +261,6 @@ l() { ls --long --binary --git --time-style=iso --header $@ } -re() { - systemctl restart $@ -} - -ure() { - systemctl --user restart $@ -} - ssh-installer() { ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentityFile=~/.ssh/gkleen@sif.midgard.yggdrasil $@ } -- cgit v1.2.3