diff --git a/home/default.nix b/home/default.nix index fe1882c..15083e2 100644 --- a/home/default.nix +++ b/home/default.nix @@ -22,7 +22,6 @@ in ./gtk.nix ./misc.nix ./persistence.nix - ./scripts.nix ./wm ./programs ./services diff --git a/home/scripts.nix b/home/scripts.nix deleted file mode 100644 index df9095f..0000000 --- a/home/scripts.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ osConfig, pkgs, ... }: -{ - xdg.configFile = { - "scripts/chpaper.sh" = { - text = '' - #!/bin/sh - - set -eu - - DIR="''${HOME}/.local/share/wallpapers" - - random_paper() { - find -L "''${DIR}"/ -type f -regextype egrep -regex ".*\.(jpe?g|png)$" | shuf -n1 - } - - SWAYSOCK="''${SWAYSOCK:-""}" - if [ -z "''${SWAYSOCK}" ] ; then - SWAYSOCK="$(find /run/user/"$(id -u)"/ -name "sway-ipc.$(id -u).*.sock")" - export SWAYSOCK - fi - ${pkgs.imagemagick}/bin/convert "$(random_paper)" /tmp/wallpaper.jpg && swaymsg "output * bg '/tmp/wallpaper.jpg' fill" & - ${pkgs.imagemagick}/bin/convert "$(random_paper)" /tmp/lockpaper.jpg - ''; - executable = true; - }; - }; -} diff --git a/packages/scripts/chpaper.sh b/packages/scripts/chpaper.sh new file mode 100644 index 0000000..84f98e4 --- /dev/null +++ b/packages/scripts/chpaper.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -eu + +DIR="$1" +if [ ! -d "$DIR" ]; then + echo "$DIR: not a directory" + exit 1 +fi + +random_paper() { + find -L "${DIR}"/ -type f -regextype egrep -regex ".*\.(jpe?g|png)$" | shuf -n1 +} + +convert "$(random_paper)" /tmp/wallpaper.jpg && swaybg -i "/tmp/wallpaper.jpg" -m fill & +convert "$(random_paper)" /tmp/lockpaper.jpg diff --git a/packages/scripts/default.nix b/packages/scripts/default.nix index 145393d..693d7ca 100644 --- a/packages/scripts/default.nix +++ b/packages/scripts/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenvNoCC, makeWrapper, libnotify, rofi-wayland, tmux, kitty }: +{ lib, stdenvNoCC, makeWrapper, libnotify, rofi-wayland, tmux, kitty, iagemagick, swaybg }: stdenvNoCC.mkDerivation { pname = "scripts"; @@ -17,5 +17,9 @@ stdenvNoCC.mkDerivation { cp tmux-sessions.sh $out/bin/tmux-sessions chmod +x $out/bin/tmux-sessions wrapProgram $out/bin/tmux-sessions --prefix PATH : ${lib.makeBinPath [ tmux kitty rofi-wayland ]} + + cp chpaper.sh $out/bin/chpaper + chmod +x $out/bin/chpaper + wrapProgram $out/bin/chpaper --prefix PATH : ${lib.makeBinPath [ imagemagick swaybg ]} ''; }