From 677c2c0591e8a06d7993468c5aa816125bb122d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Pizarro?= Date: Tue, 24 Dec 2024 21:13:43 -0300 Subject: [PATCH 1/3] fix: sed command is added to replace ~ with the value of the /home/martin variable, because the file saves the path of the chosen wallpaper with the reference ~ and the wallpaper-restore script cannot find the file --- .../.config/hypr/scripts/wallpaper-restore.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/share/dotfiles/.config/hypr/scripts/wallpaper-restore.sh b/share/dotfiles/.config/hypr/scripts/wallpaper-restore.sh index 9c6cd6e5..2eb7d7c7 100755 --- a/share/dotfiles/.config/hypr/scripts/wallpaper-restore.sh +++ b/share/dotfiles/.config/hypr/scripts/wallpaper-restore.sh @@ -21,16 +21,17 @@ cachefile="$HOME/.config/ml4w/cache/current_wallpaper" # Get current wallpaper # ----------------------------------------------------- -if [ -f $cachefile ] ;then - if [ -f $(cat $cachefile) ]; then - echo ":: Wallpaper $(cat $cachefile) exists" - wallpaper=$(cat $cachefile) +if [ -f "$cachefile" ]; then + sed -i "s|~|$HOME|g" "$cachefile" + wallpaper=$(cat $cachefile) + if [ -f $wallpaper ]; then + echo ":: Wallpaper $wallpaper exists" else - echo ":: Wallpaper $(cat $cachefile) not exists." + echo ":: Wallpaper $wallpaper does not exist. Using default." wallpaper=$defaultwallpaper fi else - echo ":: $cachefile not exists." + echo ":: $cachefile does not exist. Using default wallpaper." wallpaper=$defaultwallpaper fi @@ -39,4 +40,4 @@ fi # ----------------------------------------------------- echo ":: Setting wallpaper with source image $wallpaper" -waypaper --wallpaper $wallpaper \ No newline at end of file +waypaper --wallpaper "$wallpaper" From 636cb4df96c504fbd5a53ab3954da7d14d44c4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Pizarro?= Date: Tue, 24 Dec 2024 21:19:42 -0300 Subject: [PATCH 2/3] feat: Added 1600x900 resolution --- share/dotfiles/.config/hypr/conf/monitors/1600x900.conf | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 share/dotfiles/.config/hypr/conf/monitors/1600x900.conf diff --git a/share/dotfiles/.config/hypr/conf/monitors/1600x900.conf b/share/dotfiles/.config/hypr/conf/monitors/1600x900.conf new file mode 100644 index 00000000..ef2ba49b --- /dev/null +++ b/share/dotfiles/.config/hypr/conf/monitors/1600x900.conf @@ -0,0 +1,6 @@ +# ----------------------------------------------------- +# Monitor Setup +# name: "1600x900" +# ----------------------------------------------------- + +monitor=,1600x900,auto,1 From 105f66cef16bfd1f2c876def62f30bcb684a1009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Pizarro?= Date: Tue, 24 Dec 2024 21:32:19 -0300 Subject: [PATCH 3/3] feat: Added script to listen for changes in the config.ini file generated by waypaper, once a change is detected in the wallpaper property, the path of the new wallpaper is saved in the cache file located at ~/.config/ml4w/cache/current_wallpaper --- .../dotfiles/.config/hypr/conf/autostart.conf | 3 +++ .../ml4w/scripts/listen_wallpaper_change.sh | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100755 share/dotfiles/.config/ml4w/scripts/listen_wallpaper_change.sh diff --git a/share/dotfiles/.config/hypr/conf/autostart.conf b/share/dotfiles/.config/hypr/conf/autostart.conf index ee079c92..1435c546 100644 --- a/share/dotfiles/.config/hypr/conf/autostart.conf +++ b/share/dotfiles/.config/hypr/conf/autostart.conf @@ -10,6 +10,9 @@ exec-once = ~/.config/hypr/scripts/xdg.sh # Load Wallpaper exec-once = ~/.config/hypr/scripts/wallpaper-restore.sh +# Listen wallpaper changes +exec=once = nohup sh ~/.config/hypr/conf/autostart.conf & + # Start Polkit exec-once=/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 diff --git a/share/dotfiles/.config/ml4w/scripts/listen_wallpaper_change.sh b/share/dotfiles/.config/ml4w/scripts/listen_wallpaper_change.sh new file mode 100755 index 00000000..c13d099e --- /dev/null +++ b/share/dotfiles/.config/ml4w/scripts/listen_wallpaper_change.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CURRENT_WALLPAPER_PATH=$HOME/hyprland-setup/dotfiles/dot_config/ml4w/cache/current_wallpaper +CONFIG_FILE=$HOME/hyprland-setup/dotfiles/dot_config/waypaper/config.ini +LAST_WALLPAPER="" + +get_current_wallpaper() { + grep -oP '^wallpaper\s*=\s*\K.*' "$CONFIG_FILE" +} + +LAST_WALLPAPER=$(get_current_wallpaper) + +inotifywait -m -e modify "$CONFIG_FILE" | while read -r path event file; do + CURRENT_WALLPAPER=$(get_current_wallpaper) + + if [[ "$CURRENT_WALLPAPER" != "$LAST_WALLPAPER" ]]; then + LAST_WALLPAPER=$CURRENT_WALLPAPER + echo "El wallpaper ha cambiado: $CURRENT_WALLPAPER" + rm $CURRENT_WALLPAPER_PATH || true + touch $CURRENT_WALLPAPER_PATH || true + echo "$LAST_WALLPAPER" >> $CURRENT_WALLPAPER_PATH + sed -i "s|~|$HOME|g" "$CURRENT_WALLPAPER_PATH" + fi + sleep 0.01 +done