summaryrefslogtreecommitdiff
path: root/home
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-06-26 23:40:26 -0700
committerFuwn <[email protected]>2024-06-26 23:40:26 -0700
commitfb080b69ae76802739e598ca809feb116e78ae9f (patch)
treeac8e1d98d666113ce58143c0d2ef9f5d16cfa8db /home
parentchanges (diff)
downloadhome-manager-config-fb080b69ae76802739e598ca809feb116e78ae9f.tar.xz
home-manager-config-fb080b69ae76802739e598ca809feb116e78ae9f.zip
f
Diffstat (limited to 'home')
-rw-r--r--home/fuwn/meta/rice/default.nix1
-rwxr-xr-xhome/fuwn/meta/scripts/scripts/setbg75
2 files changed, 76 insertions, 0 deletions
diff --git a/home/fuwn/meta/rice/default.nix b/home/fuwn/meta/rice/default.nix
index 56e4bc1..333be98 100644
--- a/home/fuwn/meta/rice/default.nix
+++ b/home/fuwn/meta/rice/default.nix
@@ -5,5 +5,6 @@ _: {
./cpufetch
./fastfetch
./iotop
+ ./pywal
];
}
diff --git a/home/fuwn/meta/scripts/scripts/setbg b/home/fuwn/meta/scripts/scripts/setbg
new file mode 100755
index 0000000..a399344
--- /dev/null
+++ b/home/fuwn/meta/scripts/scripts/setbg
@@ -0,0 +1,75 @@
+background_location="${XDG_DATA_HOME:-${HOME}/.local/share}/bg"
+dunst_configuration_file="${XDG_CONFIG_HOME:-${HOME}/.config}/dunst/dunstrc"
+zathura_configuration_file="${XDG_CONFIG_HOME:-${HOME}/.config}/zathura/zathurarc"
+
+while getopts "s" o; do case "${o}" in
+ s) silent='1' ;;
+ *) ;;
+ esac done
+
+shift $((OPTIND - 1))
+
+true_background_location="$(readlink -f "$1")" &&
+ case "$(file --mime-type -b "${true_background_location}")" in
+ image/*)
+ ln -sf "${true_background_location}" "${background_location}" &&
+ [ -z "${silent}" ] &&
+ notify-send -i "${background_location}" "Changing wallpaper ..."
+ ;;
+ inode/directory)
+ link=$(find "${true_background_location}" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)
+
+ ln -sf "${link}" "${background_location}" && [ -z "${silent}" ] && notify-send -i "${background_location}" "Random wallpaper chosen."
+ ;;
+ *)
+ [ -z "${silent}" ] &&
+ notify-send "Error" "Invalid image or directory found."
+
+ exit 1
+ ;;
+ esac
+
+if command -v wal >/dev/null 2>&1; then
+ link=$(readlink -f "${background_location}")
+
+ wal -n -i "${link}" -o "${XDG_CONFIG_HOME:-${HOME}/.config}/wal/postrun" >/dev/null 2>&1
+else
+ [ -f "${dunst_configuration_file}.bak" ] &&
+ unlink "${dunst_configuration_file}" &&
+ mv "${dunst_configuration_file}.bak" "${dunst_configuration_file}"
+
+ [ -f "${zathura_configuration_file}.bak" ] &&
+ unlink "${zathura_configuration_file}" &&
+ mv "${zathura_configuration_file}.bak" "${zathura_configuration_file}"
+fi
+
+case "$(loginctl show-session 1 -p Type)" in
+*"wayland")
+ hyprpaper_configuration_file="${HOME}/.config/hypr/hyprpaper.conf"
+
+ cp "${HOME}/.cache/wal/colors-waybar.css" "${HOME}/.config/waybar/colors-waybar.css"
+ cp "${hyprpaper_configuration_file}" "${hyprpaper_configuration_file}.bak"
+
+ if pidof hyprpaper >/dev/null; then
+ awk -v newpath="${true_background_location}" '
+BEGIN { FS = OFS = "=" }
+/^preload/ {
+ $2 = " " newpath
+}
+/^wallpaper/ {
+ split($2, a, ",");
+ $2 = a[1] "," newpath
+}
+{ print }
+' "${hyprpaper_configuration_file}.bak" >"${hyprpaper_configuration_file}"
+ killall -9 hyprpaper >/dev/null
+ hyprpaper >/dev/null &
+ elif pidof swww-daemon >/dev/null; then
+ swww img "${true_background_location}" &
+ fi
+ ;;
+*)
+ xwallpaper --zoom "${background_location}"
+ pidof sei >/dev/null && xdotool key super+F5
+ ;;
+esac