dotfiles/private_dot_local/bin/executable_setupwallpaper

67 lines
1.9 KiB
Bash

#!/bin/bash
export DISPLAY=:0
export BATTERY=BAT0
source /etc/lsb-release
wp_folder="${HOME}/images/wallpapers";
base_background="#131313";
textpos_1="0,665"; text_c1="#cfcfcf";
textpos_2="0,680"; text_c2="#cfcfcf";
textpos_s_1="1,666"; text_s_c1="#131313";
textpos_s_2="1,681"; text_s_c2="#131313";
text_1="$(date +"%a %Y-%m-%d")"; text_2=""
export SOULMATE="Dia"
export OTHER_ROLE="wife"
splash_text="$1";
if [ "$splash_text" = "" ]; then
splash_text="$(sort -R ~/.local/share/splashes.txt | grep -vP '^#' | grep -vP '^\s+$' | head -n 1)";
echo "$(date +%s) $splash_text" | tee -a ~/.local/share/splashes.log;
splash_text="$(echo -n "$splash_text" | jq -r)";
splash_text="$(eval "echo -n \"$splash_text\"")";
fi;
text_2="${splash_text}";
source_image="$wp_folder/wallpaper.png";
#if [[ "$(date +%a)" = "Fri" ]]; then
# source_image="$wp_folder/friday2.png";
#fi
if [[ "$source_image" = "${wp_folder}/friday2.png" ]]; then
textpos_1="0,420";
textpos_2="0,435";
fi
errors=" ";
bat_energy_full=$(cat /sys/class/power_supply/$BATTERY/energy_full);
bat_energy_design=$(cat /sys/class/power_supply/$BATTERY/energy_full_design);
bat_health=$((bat_energy_full * 100 / bat_energy_design));
if [ ${bat_health} -le 50 ]; then
errors="${errors}
[E:PWR] Low battery health (${bat_health}%)";
fi
convert "$source_image" \
-font "Unifont" \
-pointsize 16 \
-draw "gravity North \
fill ${text_s_c1} text ${textpos_s_1}'${text_1}' \
fill ${text_s_c2} text ${textpos_s_2}'${text_2}' \
fill ${text_c1} text ${textpos_1}'${text_1}' \
fill ${text_c2} text ${textpos_2}'${text_2}'; \
gravity NorthWest \
fill #efefef text 8,20'${errors}'" \
/tmp/current-wallpaper.png; # 2>/dev/null;
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
killall swaybg;
swaybg -i /tmp/current-wallpaper.png -m center & disown;
else
hsetroot -solid "$base_background" -center /tmp/current-wallpaper.png;
fi;