Skip to content

Instantly share code, notes, and snippets.

@koonix
Last active June 21, 2022 12:15
Show Gist options
  • Save koonix/e5ff08b3c35f9b87c30a55c93b60b0f9 to your computer and use it in GitHub Desktop.
Save koonix/e5ff08b3c35f9b87c30a55c93b60b0f9 to your computer and use it in GitHub Desktop.
bash script to set a video or gif as the wallpaper. requires mpv, xrandr and xwinwrap.
#!/bin/bash
#
# 2022-06-21
# version: 0.1.1
# author: Ehsan Ghorbannezhad <[email protected]>
#
# sets a video or gif as your wallpaper.
# requires mpv, xwinwrap and xrandr.
main()
{
local wallpaper=$1
set_wallpaper_all_displays "$wallpaper"
}
set_wallpaper_all_displays()
{
local wallpaper=$1
for geom in $(get_display_geometries); do
set_wallpaper "$wallpaper" "$geom" &
done
wait
}
set_wallpaper()
{
local wallpaper=$1
local geom=$2
xwinwrap -ov -ni -g "$geom" -- mpv "${mpv_args[@]}" -- "$wallpaper"
}
get_display_geometries()
{
xrandr -q | grep -Po ' connected \D+\K\d+x\d+\+\d+\+\d+'
}
mpv_args=(
--fullscreen
--loop-file
--no-audio
--sid=no
--no-osc
--no-osd-bar
--no-input-default-bindings
--no-stop-screensaver
--load-scripts=no
--msg-level=all=error
-wid %WID
)
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment