Create set-wallpaper script

This commit is contained in:
2021-10-20 12:17:25 +03:00
parent a0eed7adfa
commit d140b82678
3 changed files with 40 additions and 9 deletions

View File

@@ -1,5 +0,0 @@
#! /bin/bash
killall mpvpaper
mpvpaper -o "no-audio" VGA-1 ~/Videos/Witcher-3.mp4

39
bin/set-wallpaper Executable file
View File

@@ -0,0 +1,39 @@
#! /bin/bash
arg=$1
if [[ "$arg" == "" ]] ; then
echo "Usage: set-wallpaper [--restore]|[/path/to/image/or/video]"
exit
fi
set_wallpaper() {
killall mpvpaper 2>> /dev/null
killall swaybg 2>> /dev/null
echo $1
if [[ "$1" == *.mkv || "$1" == *.mov || "$1" == *mp4 ]] ; then
echo "Setting video wallpaper using mpvpaper"
/sbin/mpvpaper -o "no-audio" VGA-1 $1
echo "Video wallpaper has been set"
elif [[ "$1" == *.jpeg || "$1" == *.jpg || "$1" == *.png ]] ; then
echo "Setting image wallpaper using swaybg"
/sbin/swaybg -i $1 -m fill &
echo "Image wallpaper has been set"
fi
}
if [[ "$arg" == "--restore" ]] ; then
path=$(cat $HOME/.wallpaper)
set_wallpaper $path
else
echo "$arg" > $HOME/.wallpaper
echo "Saved $arg as a wallpaper but you need to run 'set-wallpaper --restore'"
fi

View File

@@ -43,9 +43,6 @@ gaps inner 10
floating_modifier $mod normal
font FiraCode 10
# Draw wallpaper
# output * bg `$HOME/dotfiles/bin/get-random-wallpaper.py` fill
# Keyboard layout
input * {
xkb_layout "us,ru"
@@ -87,7 +84,7 @@ for_window [class="MuPDF"] floating enable
#
exec_always --no-startup-id $HOME/.config/waybar/launch.sh
exec_always --no-startup-id dunst
exec_always --no-startup-id $HOME/dotfiles/bin/set-video-wallpaper
exec_always --no-startup-id $HOME/dotfiles/bin/set-wallpaper --restore