dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 41c3f8db847d7c3ec05363f4923ad41a4290ccd2
parent aefbb05d139e074086b11469e7464e0780c23de2
Author: Alex Balgavy <EMAIL>
Date:   Sat,  7 Sep 2019 15:57:28 -0400

gnome-background: test and set backgrounds in GNOME

Former-commit-id: 77cfdc7b94c0e50b4a4157dfb9ba1405e51855b9
Diffstat:
Ascripts/gnome-background | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+), 0 deletions(-)

diff --git a/scripts/gnome-background b/scripts/gnome-background @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +die() { + echo "$1" >&2 + exit 1 +} +loop_backgrounds() { + for i in /home/zeroalpha/Pictures/Backgrounds/"$1"/*; do + gsettings set org.gnome.desktop.background picture-uri "$i"; + echo -n "$i: "; + echo "press enter to continue, c to copy"; + read -rsn 1 key; + if [ "$key" = "c" ]; then + if ! command -v xclip &>/dev/null; then + echo "xclip not installed." >&2 + else + xclip -sel clip <<< "$i" + echo "copied" + fi + fi + done +} +temp_set_background() { + echo "Setting to $1" + gsettings set org.gnome.desktop.background picture-uri "file://$1"; + echo "Press enter to continue." + read -rsn 1 c; + reset_background +} +[ -d /home/zeroalpha/Pictures/Backgrounds ] || die "No backgrounds folder." + +save_current() { + current=$(gsettings get org.gnome.desktop.background picture-uri) + trap reset_background INT TERM KILL EXIT +} +reset_background() { + gsettings set org.gnome.desktop.background picture-uri "$current"; + trap - INT TERM KILL EXIT + exit 0 +} +if [ "$1" = "audition" ]; then + [ $# -eq 2 ] || die "Light or dark?" + save_current + loop_backgrounds "$2" +elif [ "$1" = "test" ]; then + [ $# -eq 2 ] || die "No background provided." + save_current + temp_set_background "$2" +elif [ "$1" = "print" ]; then + gsettings get org.gnome.desktop.background picture-uri; +else + if [ $# -eq 1 ]; then + echo "Setting background to $1" + gsettings set org.gnome.desktop.background picture-uri "file://$1"; + fi +fi