From 875c5b832eb95a01b5e59ec009a7f76ff4f43e92 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 21 Apr 2021 17:25:08 -0700 Subject: update handling of wallpapers for use of Sway --- .config/sway/config | 6 ++++++ .config/sway/melete/bg | 13 ------------- bin/choose-wallpaper | 42 ++++++++++++++++++++++++++++++++++++++++++ bin/i3-wallpaper | 38 -------------------------------------- perl5/Local/Desktop.pm | 2 +- 5 files changed, 49 insertions(+), 52 deletions(-) delete mode 100644 .config/sway/melete/bg create mode 100755 bin/choose-wallpaper delete mode 100755 bin/i3-wallpaper diff --git a/.config/sway/config b/.config/sway/config index 25ca1f01..6fe0d846 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -349,4 +349,10 @@ exec update-emacs-daemon-environment exec_always fcitx5 -d --replace +# Set solid colour as a fallback; select-wallpaper script in combination with +# HAS-WALLPAPERS-ON-OUTPUTS Consfigurator property can be used to write +# ~/.config/sway/$(hostname)/bg to set images on this machine's usual outputs, +# and to start up swayidle with appropriate options. +output * bg #FFFFF6 solid_color + include ~/.config/sway/$(hostname)/* diff --git a/.config/sway/melete/bg b/.config/sway/melete/bg deleted file mode 100644 index 53a8cdf0..00000000 --- a/.config/sway/melete/bg +++ /dev/null @@ -1,13 +0,0 @@ -output "eDP-1" bg $HOME/local/wallpaper.png fill - -# ideally we wouldn't try to call swaylock if the screen is already locked, -# but discovering whether swaylock is already running in a way that avoids -# races is difficult or impossible because swaylock doesn't have a mechanism -# to report that it's successfully locked the screen other than daemonising. -# so, until it does, the following means a lot of "failed to lock; already -# locked?" messages on stderr. -exec swayidle -w \ - lock 'swaylock -f' \ - before-sleep 'swaylock -f -i eDP-1:$HOME/local/wallpaper.png -s fill' \ - timeout 300 'swaylock -f -i eDP-1:$HOME/local/wallpaper.png -s fill' \ - timeout 300 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' diff --git a/bin/choose-wallpaper b/bin/choose-wallpaper new file mode 100755 index 00000000..648c1a6b --- /dev/null +++ b/bin/choose-wallpaper @@ -0,0 +1,42 @@ +#!/usr/bin/perl + +use 5.028; +use strict; +use warnings; +use lib "$ENV{HOME}/src/dotfiles/perl5"; + +use Local::Desktop; +use File::Copy; + +my $x11 = $ENV{XDG_SESSION_TYPE} && $ENV{XDG_SESSION_TYPE} eq "x11"; + +# dirs where wallpaper can be found +our @dirs = ("$ENV{HOME}/annex/wallpaper/pro"); + +if (@ARGV and $ARGV[0] eq "--check-have") { + ensure_resize_for_current_outputs if $x11; + exit !<"$ENV{HOME}/local/wallpaper??.*">; +} + +die "need --random and/or some image files" unless @ARGV; + +my @wallpapers; +if ($ARGV[0] eq "--random") { + shift; + push @wallpapers, pick_random_wallpapers 4, @dirs; +} +unshift @wallpapers, @ARGV; +select_wallpaper_files @wallpapers; + +if ($x11) { + resize_for_current_outputs; + system "i3-startup-always"; # feh and also restart i3lock +} + +# now give develacc something +if (-e "$ENV{HOME}/local/develacc") { + my $develacc_wallpaper = @ARGV ? $ARGV[$#ARGV] : $wallpapers[$#wallpapers]; + my ($ext) = $develacc_wallpaper =~ /\.([^.]+)\z/; + copy $develacc_wallpaper, + "$ENV{HOME}/local/develacc/local/wallpaper00.$ext"; +} diff --git a/bin/i3-wallpaper b/bin/i3-wallpaper deleted file mode 100755 index 5d5b95a6..00000000 --- a/bin/i3-wallpaper +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/perl - -use 5.028; -use strict; -use warnings; -use lib "$ENV{HOME}/src/dotfiles/perl5"; - -use Local::Desktop; -use File::Copy; - -# dirs where wallpaper can be found -our @dirs = ("$ENV{HOME}/annex/wallpaper/pro"); - -if (@ARGV and $ARGV[0] eq "--check-have") { - ensure_resize_for_current_outputs; - exit !<"$ENV{HOME}/local/wallpaper??.*">; -} - -die "need --random and/or some image files" unless @ARGV; - -my @wallpapers; -if ($ARGV[0] eq "--random") { - shift; - push @wallpapers, pick_random_wallpapers 4, @dirs; -} -unshift @wallpapers, @ARGV; -select_wallpaper_files @wallpapers; - -resize_for_current_outputs; -system "i3-startup-always"; # feh and also restart i3lock - -# now give develacc something -if (-e "$ENV{HOME}/local/develacc") { - my $develacc_wallpaper = @ARGV ? $ARGV[$#ARGV] : $wallpapers[$#wallpapers]; - my ($ext) = $develacc_wallpaper =~ /\.([^.]+)\z/; - copy $develacc_wallpaper, - "$ENV{HOME}/local/develacc/local/wallpaper00.$ext"; -} diff --git a/perl5/Local/Desktop.pm b/perl5/Local/Desktop.pm index 46a62bbf..3ca93b90 100644 --- a/perl5/Local/Desktop.pm +++ b/perl5/Local/Desktop.pm @@ -69,7 +69,7 @@ Returns the value of $? right after executing convert(1). sub resize_for_current_outputs { # note that swaybg and swaylock have per-output wallpapers built in, so - # hopefully someday this function will be obsolete ... + # this function is only for X11 chomp(my @xrandr = `xrandr`); my ($canvas_w, $canvas_h) = _get_screen_size(@xrandr); -- cgit v1.2.3