move chpaper script into package
This commit is contained in:
parent
6af4b871c3
commit
07a2ab674e
4 changed files with 21 additions and 29 deletions
|
@ -22,7 +22,6 @@ in
|
||||||
./gtk.nix
|
./gtk.nix
|
||||||
./misc.nix
|
./misc.nix
|
||||||
./persistence.nix
|
./persistence.nix
|
||||||
./scripts.nix
|
|
||||||
./wm
|
./wm
|
||||||
./programs
|
./programs
|
||||||
./services
|
./services
|
||||||
|
|
|
@ -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;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
16
packages/scripts/chpaper.sh
Normal file
16
packages/scripts/chpaper.sh
Normal file
|
@ -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
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, stdenvNoCC, makeWrapper, libnotify, rofi-wayland, tmux, kitty }:
|
{ lib, stdenvNoCC, makeWrapper, libnotify, rofi-wayland, tmux, kitty, iagemagick, swaybg }:
|
||||||
|
|
||||||
stdenvNoCC.mkDerivation {
|
stdenvNoCC.mkDerivation {
|
||||||
pname = "scripts";
|
pname = "scripts";
|
||||||
|
@ -17,5 +17,9 @@ stdenvNoCC.mkDerivation {
|
||||||
cp tmux-sessions.sh $out/bin/tmux-sessions
|
cp tmux-sessions.sh $out/bin/tmux-sessions
|
||||||
chmod +x $out/bin/tmux-sessions
|
chmod +x $out/bin/tmux-sessions
|
||||||
wrapProgram $out/bin/tmux-sessions --prefix PATH : ${lib.makeBinPath [ tmux kitty rofi-wayland ]}
|
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 ]}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue