[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.
This commit is contained in:
Lucien Cartier-Tilet 2021-01-04 14:04:23 +01:00
parent fc497a5fd9
commit 552c91b473
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -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