scripts: improve launch_wallpaper script
Also fallback to /run/user/$UID for XDG_RUNTIME_DIR in other scripts.
This commit is contained in:
parent
a92193776d
commit
a2d843d72e
|
@ -1,16 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# In case of using seatd (need the user to be in 'seat' group)
|
||||
# (gnupg and podman hardcode /run/user/$UID for some functions)
|
||||
# A better solution is using pam_rundir module
|
||||
if [ -z "${XDG_RUNTIME_DIR}" ]; then
|
||||
userid=$(id -u ${USER})
|
||||
export XDG_RUNTIME_DIR="$(mktemp -d /tmp/${userid}-runtime-XXXXXX)"
|
||||
[ ! -d "${XDG_RUNTIME_DIR}" ] && mkdir -p "${XDG_RUNTIME_DIR}"
|
||||
chmod 0700 "${XDG_RUNTIME_DIR}"
|
||||
fi
|
||||
|
||||
# Valid values: seatd, logind
|
||||
# Force the seat backend (seatd/logind) here if necessary
|
||||
#export LIBSEAT_BACKEND=logind
|
||||
|
||||
# GTK
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
pid=$(cat "$XDG_RUNTIME_DIR/containerd-rootless/child_pid")
|
||||
pid=$(cat "${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/containerd-rootless/child_pid")
|
||||
exec nsenter \
|
||||
--no-fork \
|
||||
--wd="$HOME" \
|
||||
|
|
|
@ -1,36 +1,47 @@
|
|||
#!/bin/sh
|
||||
|
||||
dir="$HOME/Pictures/Wallpapers/"
|
||||
running_sway=$(find "$XDG_RUNTIME_DIR" -type s -prune -name 'sway-ipc.*.sock')
|
||||
sway_socket=$(find "${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" -type s -prune -name 'sway-ipc.*.sock' 2>/dev/null)
|
||||
|
||||
if [ -n "$running_sway" ]; then
|
||||
outputs=$(swaymsg -t get_outputs | grep "name" | awk '{print $2}' | sed 's/\",*//g')
|
||||
if [ -S "$sway_socket" ]; then
|
||||
outputs=$(swaymsg -r -t get_outputs | jq -r .[].name)
|
||||
else
|
||||
outputs=$(wlr-randr | grep -E '".*\(.*\)"' | awk '{print $1}')
|
||||
outputs=$(wlr-randr --json | jq -r .[].name)
|
||||
fi
|
||||
|
||||
num_outputs=$(echo "$outputs" | wc -l)
|
||||
|
||||
wallpapers=$(find "$dir" -type f -o -type l \
|
||||
-name "*.png" \
|
||||
-o -name "*.jpg" \
|
||||
-o -name "*.jpeg" \
|
||||
-o -name "*.webp" \
|
||||
{% if wallpaper_engine == 'swww' %}
|
||||
-o -name "*.gif" \
|
||||
{% endif %}
|
||||
-o -name "*.PNG" \
|
||||
-o -name "*.JPG" \
|
||||
-o -name "*.JPEG" \
|
||||
-o -name "*.gif")
|
||||
-o -name "*.WEBP" | \
|
||||
shuf -z -n "$num_outputs")
|
||||
|
||||
num_wallpapers=$(echo "$wallpapers" | wc -l)
|
||||
|
||||
{% set get_output_cmd = '$(echo "$outputs" | sed -n "${i}p")' -%}
|
||||
{% set get_wallpaper_cmd = '$(echo "$wallpapers" | sed -n "$([ "$i" -ge "$num_wallpapers" ] && printf "%d" "$num_wallpapers" || printf "%d" "$i")p")' -%}
|
||||
{% if wallpaper_engine == 'swaybg' %}
|
||||
options=""
|
||||
for i in ${outputs}; do
|
||||
options="${options}--output ${i} --image $(shuf -z -n 1 -e ${wallpapers}) --mode fill "
|
||||
args=""
|
||||
for i in $(seq 1 "$num_outputs"); do
|
||||
args="${args} --output "{{ get_output_cmd }}" --image "{{ get_wallpaper_cmd }}" --mode fill"
|
||||
done
|
||||
exec swaybg ${options}
|
||||
exec swaybg ${args}
|
||||
{% elif wallpaper_engine == 'swww' %}
|
||||
for i in ${outputs}; do
|
||||
for i in $(seq 1 "$num_outputs"); do
|
||||
swww img \
|
||||
--transition-type random \
|
||||
--transition-step 10 \
|
||||
--filter Lanczos3 \
|
||||
--outputs "$i" \
|
||||
"$(shuf -z -n 1 -e ${wallpapers})"
|
||||
--outputs "{{ get_output_cmd }}" \
|
||||
"{{ get_wallpaper_cmd }}"
|
||||
done
|
||||
{% endif %}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
export MPD_HOST="{{ ansible_env.XDG_RUNTIME_DIR }}/mpd.sock"
|
||||
export MPD_HOST="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/mpd.sock"
|
||||
menu="{{ launcher }} {{ dmenu_flag }}"
|
||||
|
||||
status=" "
|
||||
|
|
Loading…
Reference in New Issue