redo wallpaper scripts

This commit is contained in:
Adithya 2023-05-18 16:06:40 +05:30
parent 619679f1d9
commit f8c60bb932
Signed by: adtya
GPG key ID: 48FC9915FFD326D0
3 changed files with 12 additions and 5 deletions

5
packages/scripts/chpaper.sh Normal file → Executable file
View file

@ -16,5 +16,8 @@ random_paper() {
find -L "${DIR}"/ -type f -regextype egrep -regex ".*\.(jpe?g|png)$" | shuf -n1
}
convert "$(random_paper)" /tmp/wallpaper.jpg && (pkill swaybg; swaybg -i "/tmp/wallpaper.jpg" -m fill &)
swww query || swww init
convert "$(random_paper)" /tmp/wallpaper.jpg && swww img "/tmp/wallpaper.jpg"
convert "$(random_paper)" /tmp/lockpaper.jpg
notify-send -r 9897 -i information -t 1000 "Wallpaper" "Wallpaper changed."

View file

@ -1,4 +1,4 @@
{ lib, stdenvNoCC, makeWrapper, libnotify, rofi-wayland, tmux, kitty, imagemagick, swaybg, sway, hyprland, jq, curl }:
{ lib, stdenvNoCC, makeWrapper, libnotify, rofi-wayland, tmux, kitty, imagemagick, sway, hyprland, swww, jq, curl }:
stdenvNoCC.mkDerivation {
pname = "scripts";
@ -20,10 +20,10 @@ stdenvNoCC.mkDerivation {
cp chpaper.sh $out/bin/chpaper
chmod +x $out/bin/chpaper
wrapProgram $out/bin/chpaper --prefix PATH : ${lib.makeBinPath [ imagemagick swaybg ]}
wrapProgram $out/bin/chpaper --prefix PATH : ${lib.makeBinPath [ imagemagick libnotify swww ]}
cp wallhaven.sh $out/bin/wallhaven
chmod +x $out/bin/wallhaven
wrapProgram $out/bin/wallhaven --prefix PATH : ${lib.makeBinPath [ imagemagick swaybg jq curl ]}
wrapProgram $out/bin/wallhaven --prefix PATH : ${lib.makeBinPath [ imagemagick libnotify swww jq curl ]}
'';
}

View file

@ -5,6 +5,7 @@ set -eu
wallpaper() {
FILENAME="/tmp/image-${RANDOM}"
notify-send -r 9897 -i information -t 1000 "Wallpapers" "Downloading..."
URL="https://wallhaven.cc/api/v1/search?categories=100&purity=100&atleast=1920x1080&ratios=16x9&sorting=random"
ID="$(curl --silent $URL | jq -r '.data[0].id')"
IMAGE_URL="$(curl --silent "https://wallhaven.cc/api/v1/w/$ID" | jq -r '.data.path')"
@ -13,5 +14,8 @@ wallpaper() {
echo $FILENAME
}
convert "$(wallpaper)" "/tmp/wallpaper.jpg" && (pkill swaybg; swaybg -i "/tmp/wallpaper.jpg" -m fill &)
swww query || swww init
convert "$(wallpaper)" "/tmp/wallpaper.jpg" && swww img "/tmp/wallpaper.jpg"
convert "$(wallpaper)" "/tmp/lockpaper.jpg"
notify-send -r 9897 -i information -t 1000 "Wallpaper" "Wallpaper changed."