[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
1 changed files with 6 additions and 9 deletions

View File

@ -1664,16 +1664,14 @@ Now, if the variable ~URL~ is not empty (i.e. the user specified a link and did
:END: :END:
** pape-update ** pape-update
:PROPERTIES: :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 :CUSTOM_ID: pape-update-bdecbadf
:END: :END:
This little tool sets a random wallpaper using xwallpaper. This little tool sets a random wallpaper using xwallpaper.
#+BEGIN_SRC fish #+BEGIN_SRC sh
set -l PAPESDIR ~/Pictures/Wallpapers PAPESDIR=$HOME/Pictures/Wallpapers
set -l PAPES (ls $PAPESDIR) PAPE=$(find $PAPESDIR -type f | sort -R | tail -1)
set -l PAPE $PAPESDIR/$PAPES[(random 1 (count $PAPES))] [[ -f $PAPE ]] && echo $PAPE > $HOME/.cache/wallpaper && xwallpaper --zoom $PAPE
echo $PAPE > $HOME/.cache/wallpaper
xwallpaper --zoom $PAPE
#+END_SRC #+END_SRC
** Select wallpaper ** 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. This script is base on what sxiv can do as an image viewer as well as xwallpaper.
#+BEGIN_SRC sh #+BEGIN_SRC sh
PAPE=$(sxiv -orbft ~/Pictures/Wallpapers/*) PAPE=$(sxiv -orbft ~/Pictures/Wallpapers/*)
echo $PAPE > ~/.cache/wallpaper [[ -f $PAPE ]] && echo $PAPE > ~/.cache/wallpaper && xwallpaper --zoom $PAPE
xwallpaper --zoom $PAPE
#+END_SRC #+END_SRC
* Weather * Weather