scripts: deleted 2 & added config-load & edited some
This commit is contained in:
@@ -1,6 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Select image file if none is provided
|
||||
# Required tools:
|
||||
# - zenity (for file selection dialog)
|
||||
# - imagemagick (for image processing)
|
||||
# - swww (wallpaper daemon)
|
||||
# - notify-send (for notifications)
|
||||
# - change-colortheme (from scripts/change-colortheme)
|
||||
# - flock (usually part of util-linux)
|
||||
|
||||
# Lock
|
||||
|
||||
exec {LOCK_FD}>/tmp/"$(basename "$0")".lock || {
|
||||
echo "Failed to open lock file"
|
||||
exit 1
|
||||
}
|
||||
|
||||
flock -n "$LOCK_FD" || {
|
||||
echo "Another instance is running. Exiting."
|
||||
notify-send -a "change-wallpaper" "Error" "Another instance is running. Exiting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Open a file selection dialog if no argument is provided
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
image=$(zenity --file-selection --title="Open File" --file-filter="*.jpg *.jpeg *.png *.webp *.bmp *.jfif *.tiff *.avif *.heic *.heif")
|
||||
else
|
||||
|
||||
34
scripts/config-load
Executable file
34
scripts/config-load
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
path="$(dirname "$(readlink -f "$0")")"
|
||||
backupDir="$HOME/.config/config-backup/$(date +%Y%m%d-%H%M%S)"
|
||||
backupDirCreated=0
|
||||
|
||||
sources=""
|
||||
if [ -z "$1" ]; then
|
||||
sources=$(find "$path/../config/" -maxdepth 1 -not -path "$path/../config")
|
||||
else
|
||||
for arg in "$@"; do
|
||||
src="$path/../config/$arg"
|
||||
if [ ! -e "$src" ]; then
|
||||
echo "Error: Config '$arg' does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
sources="$sources $path/../config/$arg"
|
||||
done
|
||||
fi
|
||||
|
||||
for src in $sources; do
|
||||
name="$(basename "$src")"
|
||||
dest="$HOME/.config/$name"
|
||||
|
||||
if [ -e "$dest" ] || [ -L "$dest" ]; then
|
||||
[ "$backupDirCreated" -eq 0 ] && {
|
||||
mkdir -pv "$backupDir"
|
||||
backupDirCreated=1
|
||||
}
|
||||
mv -vf "$dest" "$backupDir/"
|
||||
fi
|
||||
|
||||
ln -sv "$(realpath --relative-to="$HOME/.config" "$src")" "$dest"
|
||||
done
|
||||
@@ -9,13 +9,18 @@ else
|
||||
fi
|
||||
|
||||
for item in "kitty" "ghostty" "wlogout"; do
|
||||
[ -L "$HOME/.config/$item" ] || exit 1
|
||||
|
||||
rm "$HOME/.config/$item"
|
||||
for target in "$item" "$item-niri"; do
|
||||
if [ -L "$HOME/.config/$target" ]; then
|
||||
rm -v "$HOME/.config/$target"
|
||||
elif [ -e "$HOME/.config/$target" ]; then
|
||||
echo "Error: $HOME/.config/$target is not a symlink." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$desktop" = "niri" ]; then
|
||||
ln -s "$path/../config/$item-niri" "$HOME/.config/$item"
|
||||
ln -sv "$path/../config/$item-niri" "$HOME/.config/$item"
|
||||
else
|
||||
ln -s "$path/../config/$item" "$HOME/.config/$item"
|
||||
ln -sv "$path/../config/$item" "$HOME/.config/$item"
|
||||
fi
|
||||
done
|
||||
@@ -42,7 +42,9 @@ def take_screenshot(filepath: Path, typeStr: str):
|
||||
ScreenshotType.AREA: f"hyprshot -z -m region -o {SCREENSHOT_DIR} -f ",
|
||||
ScreenshotType.WINDOW: f"hyprshot -z -m window -o {SCREENSHOT_DIR} -f ",
|
||||
}
|
||||
os.system(f"{cmd[type]}{filepath.name}")
|
||||
if os.system(f"{cmd[type]}{filepath.name}"):
|
||||
print("Failed to take screenshot.")
|
||||
exit(1)
|
||||
wait_until_file_exists(filepath)
|
||||
elif "niri" in currentDesktop:
|
||||
cmd = {
|
||||
@@ -53,10 +55,15 @@ def take_screenshot(filepath: Path, typeStr: str):
|
||||
niriScreenshotPath = SCREENSHOT_DIR / ".niri_screenshot.png"
|
||||
if niriScreenshotPath.exists():
|
||||
niriScreenshotPath.unlink()
|
||||
os.system(cmd[type])
|
||||
if os.system(cmd[type]):
|
||||
print("Failed to take screenshot.")
|
||||
exit(1)
|
||||
wait_until_file_exists(niriScreenshotPath)
|
||||
if niriScreenshotPath.exists():
|
||||
niriScreenshotPath.rename(filepath)
|
||||
else:
|
||||
print("Failed to take screenshot.")
|
||||
exit(1)
|
||||
wait_until_file_exists(filepath)
|
||||
else:
|
||||
print("Unsupported desktop environment.")
|
||||
@@ -120,7 +127,7 @@ if __name__ == "__main__":
|
||||
)
|
||||
n.add_action(
|
||||
"default",
|
||||
"Default",
|
||||
"Open in Editor",
|
||||
edit_callback,
|
||||
None
|
||||
)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -z "$1" ] && exit 1
|
||||
[ -z "$BRIGHTNESSCTL_DEVICE" ] && BRIGHTNESSCTL_DEVICE="auto"
|
||||
|
||||
brightnessctl -d "$BRIGHTNESSCTL_DEVICE" set "$1"
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
pgrep -f spotify-lyrics -u "$USER" && (killall spotify-lyrics -u "$USER" || exit 1)
|
||||
spotify-lyrics "$@"
|
||||
Reference in New Issue
Block a user