summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2025-03-02 16:41:27 +0100
committerJoe <rbo@gmx.us>2025-03-02 16:41:27 +0100
commitfa2b961f5e68f8d6fe9281688752294542d21313 (patch)
tree940eac72fbb73e35e924d3507d768eed845bb65a
parentup (diff)
downloaddotfiles-bsd-fa2b961f5e68f8d6fe9281688752294542d21313.tar.gz
dotfiles-bsd-fa2b961f5e68f8d6fe9281688752294542d21313.tar.bz2
dotfiles-bsd-fa2b961f5e68f8d6fe9281688752294542d21313.tar.xz
dotfiles-bsd-fa2b961f5e68f8d6fe9281688752294542d21313.tar.zst
dotfiles-bsd-fa2b961f5e68f8d6fe9281688752294542d21313.zip
waylanded
Diffstat (limited to '')
-rwxr-xr-x.local/bin/setwp42
1 files changed, 30 insertions, 12 deletions
diff --git a/.local/bin/setwp b/.local/bin/setwp
index e5fce65..5340138 100755
--- a/.local/bin/setwp
+++ b/.local/bin/setwp
@@ -5,6 +5,7 @@ use warnings;
use File::HomeDir qw(home);
use File::Copy;
use File::Find;
+use POSIX qw(setsid);
use constant {
WP_POOL => home() . '/pics/wp/'
@@ -37,20 +38,37 @@ sub choose_wp
sub set_wp
{
my ($wp) = @_;
+ my $pid;
+ my $old_pid;
return 1 if !(-r $wp) || !(-f $wp);
- system(
- FEH_PATH,
- '--no-fehbg',
- '--image-bg',
- '#1d2021',
- '--bg-fill',
- $wp,
- '--bg-fill',
- $wp,
- '--bg-fill',
- $wp
- );
+
+ if (defined $ENV{WAYLAND_DISPLAY}) {
+ $old_pid = `pidof swaybg`;
+ chomp $old_pid;
+ $pid = fork();
+ if (not $pid) {
+ setsid();
+ exec("swaybg", "--image", $wp);
+ } else {
+ sleep(1);
+ exec("kill", $old_pid);
+ }
+ }
+ else {
+ system(
+ FEH_PATH,
+ '--no-fehbg',
+ '--image-bg',
+ '#1d2021',
+ '--bg-fill',
+ $wp,
+ '--bg-fill',
+ $wp,
+ '--bg-fill',
+ $wp
+ );
+ }
return 0;
}