diff options
Diffstat (limited to '')
| -rwxr-xr-x | .local/bin/setwp | 42 | 
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;  } | 
