From 552c91b473413f9edd5a3231e60a2a46b14ca56b Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Mon, 4 Jan 2021 14:04:23 +0100 Subject: [PATCH] [Bin] set-pape now supports subdirectories, fix select-pape `set-pape' now find all files in $PAPESDIR, including subdirectories. The way the wallpaper is randomly selected is also simplified, and the script is now written in bash rather than in fish. `select-pape' now writes to $HOME/.cache/wallpaper only when a wallpaper is selected. Otherwise, nothing is done. --- org/config/bin.org | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/org/config/bin.org b/org/config/bin.org index 0332b1d..021f9dc 100644 --- a/org/config/bin.org +++ b/org/config/bin.org @@ -1664,16 +1664,14 @@ Now, if the variable ~URL~ is not empty (i.e. the user specified a link and did :END: ** pape-update :PROPERTIES: -:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/pape-update +:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/pape-update :CUSTOM_ID: pape-update-bdecbadf :END: This little tool sets a random wallpaper using xwallpaper. -#+BEGIN_SRC fish - set -l PAPESDIR ~/Pictures/Wallpapers - set -l PAPES (ls $PAPESDIR) - set -l PAPE $PAPESDIR/$PAPES[(random 1 (count $PAPES))] - echo $PAPE > $HOME/.cache/wallpaper - xwallpaper --zoom $PAPE +#+BEGIN_SRC sh + PAPESDIR=$HOME/Pictures/Wallpapers + PAPE=$(find $PAPESDIR -type f | sort -R | tail -1) + [[ -f $PAPE ]] && echo $PAPE > $HOME/.cache/wallpaper && xwallpaper --zoom $PAPE #+END_SRC ** Select wallpaper @@ -1684,8 +1682,7 @@ This little tool sets a random wallpaper using xwallpaper. This script is base on what sxiv can do as an image viewer as well as xwallpaper. #+BEGIN_SRC sh PAPE=$(sxiv -orbft ~/Pictures/Wallpapers/*) - echo $PAPE > ~/.cache/wallpaper - xwallpaper --zoom $PAPE + [[ -f $PAPE ]] && echo $PAPE > ~/.cache/wallpaper && xwallpaper --zoom $PAPE #+END_SRC * Weather