- Wallpaper Change in Command
gsettings set org.gnome.desktop.background picture-uri
- Random Change
targetDir="/home/username/Photos"
function get_next_photo() {
# Returns a random file form targetdir
files=( "$targetDir"/* )
echo "${files[RANDOM % ${#files[@]}]}"
}
function set_background() {
# Takes an absolute file path as argument. Need * for spaces in path
bg="$*"
echo "Setting background to $bg"
gsettings set org.gnome.desktop.background picture-uri "file://$bg"
}
background=$(get_next_photo)
echo "Next background is $background"
set_background $background
ref - askubuntu
- Unsplash
https://source.unsplash.com/1200x628/?penguin
URL - RES - KEYWORD
- xdyinfo
xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/'
- xrandr
xrandr --current | grep '*' | uniq | awk '{print $1}'
- sleep
sleep (3) - sleep for a specified number of seconds
sleep (1) - delay for a specified amount of time
- wait
fork (3am) - basic process management
wait (2) - wait for process to change state
- watch
watch (1) - execute a program periodically, showing output fullscreen
- cornjob
schedule expressions
https://crontab.guru/#*/1_*_*_*_*
case EXPRESSION in
PATTERN_1)
STATEMENTS
;;
PATTERN_2)
STATEMENTS
;;
PATTERN_N)
STATEMENTS
;;
*)
STATEMENTS
;;
esac
all=false
long=false
while getopts ":hal" option; do
case $option in
h) echo "usage: $0 [-h] [-a] [-l] file ..."; exit ;;
a) all=true ;;
l) long=true ;;
?) echo "error: option -$OPTARG is not implemented"; exit ;;
esac
done
# remove the options from the positional parameters
shift $(( OPTIND - 1 ))
ls_opts=()
$all && ls_opts+=( -a )
$long && ls_opts+=( -l )
# now, do it
ls "${ls_opts[@]}" "$@"
ref https://unix.stackexchange.com/questions/20975/how-do-i-handle-switches-in-a-shell-script