33 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
| #!/bin/bash
 | |
| 
 | |
| source "/usr/lib/sp-functions"
 | |
| 
 | |
| getwpno() {
 | |
|   wpno=$(printf "%02d\n" $(($(echo "$1" | awk '{print $1}' | grep -o "^[1-9]*")-1)) | cut -c 1 | sed 's/[^0-9]*//g')
 | |
|   echo "${wpno}" | tee "${cache_dir}/displays/${2}"
 | |
| }
 | |
| 
 | |
| setbg() {
 | |
|   for d in ${outputs[@]};do
 | |
|     d_wpno=$(cat "${cache_dir}/displays/${d}")
 | |
|     swaymsg output "${d}" bg "${conf_dir}/wallpaper/${d}/${d_wpno}.jpg" fill
 | |
|     wp_imgpath="${conf_dir}/wallpaper/${d}/${d_wpno}.jpg"
 | |
|     sl_imgpath="${cache_dir}/lock/${d}.jpg"
 | |
|     convert -scale 10% -blur 0x3 -resize 500% "${wp_imgpath}" "${sl_imgpath}" &
 | |
|   done
 | |
| }
 | |
| 
 | |
| output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | {name} | "\(.name)"')
 | |
| outputs=( $(swaymsg -t get_outputs | jq -r '.[] | {name} | "\(.name)"') )
 | |
| workspace=$(swaymsg -t get_workspaces | jq -r '.[] | select(.focused) | {name} | "\(.name)"')
 | |
| getwpno "${workspace}" "${output}"
 | |
| setbg "${output}" "${wpno}"
 | |
| 
 | |
| swaymsg -r -t subscribe -m '["workspace"]' | jq -rc --unbuffered 'select(.change == "focus") | .current | "\(.name) \(.output)"' | while read name output;do
 | |
|   wsno=$(($(echo "$name" | awk '{print $1}' | grep -o "^[1-9]*")-1))
 | |
|   wpno_last=$(cat "${cache_dir}/displays/${output}")
 | |
|   getwpno "${name}" "${output}"
 | |
|   if [[ "${wpno}" -ne "${wpno_last}" ]];then
 | |
|     setbg "${output}" "${wpno}"
 | |
|   fi
 | |
| done
 |