better stow (vielleicht :/
This commit is contained in:
61 files changed
+139
-19
No files matched your search
Executable
+109
@@ -0,0 +1,109 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
BASE_PKGS = [
|
||||||
|
"clang",
|
||||||
|
"scripts",
|
||||||
|
"stow"
|
||||||
|
]
|
||||||
|
|
||||||
|
TUI_PKGS = [
|
||||||
|
*BASE_PKGS,
|
||||||
|
"fastfetch",
|
||||||
|
"nvim",
|
||||||
|
"shell",
|
||||||
|
"yazi"
|
||||||
|
]
|
||||||
|
|
||||||
|
GUI_BASE_PKGS = [
|
||||||
|
*TUI_PKGS,
|
||||||
|
"kitty",
|
||||||
|
"ghostty",
|
||||||
|
"misc",
|
||||||
|
"mpv",
|
||||||
|
"wallpaper",
|
||||||
|
]
|
||||||
|
|
||||||
|
HYPRLAND_PKGS = [
|
||||||
|
*GUI_BASE_PKGS,
|
||||||
|
"eww",
|
||||||
|
"hypr",
|
||||||
|
"mako",
|
||||||
|
"rofi",
|
||||||
|
"waybar",
|
||||||
|
"wlogout"
|
||||||
|
]
|
||||||
|
|
||||||
|
NIRI_PKGS = [
|
||||||
|
*GUI_BASE_PKGS,
|
||||||
|
"niri",
|
||||||
|
"quickshell",
|
||||||
|
"rofi",
|
||||||
|
"wlogout"
|
||||||
|
]
|
||||||
|
|
||||||
|
PKGS = {
|
||||||
|
"base": BASE_PKGS,
|
||||||
|
"tui": TUI_PKGS,
|
||||||
|
"gui": GUI_BASE_PKGS,
|
||||||
|
"hyprland": HYPRLAND_PKGS,
|
||||||
|
"niri": NIRI_PKGS
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PKGS_PATH = Path(__file__).resolve().parent.resolve() / "config"
|
||||||
|
DEST_PATH = Path.home().expanduser()
|
||||||
|
|
||||||
|
|
||||||
|
def _log(level: str, message: str):
|
||||||
|
color = "\033[92m" if level == "INFO" else "\033[91m" if level == "ERROR" else "\033[0m"
|
||||||
|
reset = "\033[0m"
|
||||||
|
print(f"{color}[{level}] {message}{reset}")
|
||||||
|
|
||||||
|
|
||||||
|
def stow(pkg: str):
|
||||||
|
subprocess.run(["stow", "-v", "-d", str(PKGS_PATH), "-t", str(DEST_PATH), pkg], check=True)
|
||||||
|
|
||||||
|
|
||||||
|
def switch(session: str):
|
||||||
|
subprocess.run(["config-switch", session], check=True)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = ArgumentParser(description="Stow configuration packages.")
|
||||||
|
parser.add_argument(
|
||||||
|
"package",
|
||||||
|
choices=PKGS.keys(),
|
||||||
|
help="The configuration package to stow."
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
selected_pkgs = PKGS[args.package]
|
||||||
|
|
||||||
|
for pkg in selected_pkgs:
|
||||||
|
try:
|
||||||
|
stow(pkg)
|
||||||
|
_log("INFO", f"Successfully stowed package '{pkg}'.")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
_log("ERROR", f"Failed to stow package '{pkg}': {e}")
|
||||||
|
|
||||||
|
if args.package == "hyprland":
|
||||||
|
try:
|
||||||
|
switch("Hypr")
|
||||||
|
_log("INFO", "Switched session to hyprland.")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
_log("ERROR", f"Failed to switch session: {e}")
|
||||||
|
|
||||||
|
elif args.package == "niri":
|
||||||
|
try:
|
||||||
|
switch("niri")
|
||||||
|
_log("INFO", "Switched session to niri.")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
_log("ERROR", f"Failed to switch session: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1 @@
|
|||||||
|
.alt/ghostty-default
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
.alt/ghostty-niri
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1 @@
|
|||||||
|
.alt/kitty-default
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
.alt/kitty-niri
|
||||||
File renamed without changes.
@@ -295,7 +295,7 @@ screenshot-path "~/Pictures/Screenshots/.niri_screenshot.png"
|
|||||||
binds {
|
binds {
|
||||||
// Apps
|
// Apps
|
||||||
Mod+C { spawn-sh "code --password-store=gnome-libsecret"; }
|
Mod+C { spawn-sh "code --password-store=gnome-libsecret"; }
|
||||||
Mod+E { spawn-sh "nautilus --new-window"; }
|
Mod+E { spawn-sh "dolphin --new-window"; }
|
||||||
Mod+W { spawn-sh "zen || zen-browser"; }
|
Mod+W { spawn-sh "zen || zen-browser"; }
|
||||||
Mod+X { spawn "gnome-text-editor" "--new-window"; }
|
Mod+X { spawn "gnome-text-editor" "--new-window"; }
|
||||||
Mod+B { spawn-sh "pkill -x -n btop || ghostty -e btop"; }
|
Mod+B { spawn-sh "pkill -x -n btop || ghostty -e btop"; }
|
||||||
|
|||||||
@@ -1,27 +1,29 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
path="$(dirname "$(readlink -f "$0")")"
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
desktop="$XDG_CURRENT_DESKTOP"
|
desktop="$XDG_CURRENT_DESKTOP"
|
||||||
else
|
else
|
||||||
desktop="$1"
|
desktop="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
config_path="$path/../../.."
|
|
||||||
|
|
||||||
for item in "kitty" "ghostty" "wlogout"; do
|
for item in "kitty" "ghostty" "wlogout"; do
|
||||||
for target in "$item" "$item-niri"; do
|
if [ ! -L "$HOME/.config/$item" ] && [ -e "$HOME/.config/$item" ]; then
|
||||||
if [ ! -L "$HOME/.config/$target" ] && [ -e "$HOME/.config/$target" ]; then
|
echo "Error: $HOME/.config/$item exists and is not a symlink." >&2
|
||||||
echo "Error: $HOME/.config/$target exists and is not a symlink." >&2
|
exit 1
|
||||||
|
elif [ -L "$HOME/.config/$item" ]; then
|
||||||
|
rm "$HOME/.config/$item" || {
|
||||||
|
echo "Error: Failed to remove existing symlink $HOME/.config/$item." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
}
|
||||||
stow -t "$HOME" -d "$config_path" -D "$target"
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$desktop" = "niri" ] || [ "$desktop" = "GNOME" ]; then
|
if [ "$desktop" = "niri" ] || [ "$desktop" = "GNOME" ]; then
|
||||||
stow -t "$HOME" -d "$config_path" "$item-niri"
|
if [ -e "$HOME/.config/.alt/${item}-niri" ]; then
|
||||||
|
ln -svf ".alt/${item}-niri" "$HOME/.config/$item"
|
||||||
|
elif [ -e "$HOME/.config/.alt/${item}-default" ]; then
|
||||||
|
ln -svf ".alt/${item}-default" "$HOME/.config/$item"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
stow -t "$HOME" -d "$config_path" "$item"
|
[ -e "$HOME/.config/.alt/${item}-default" ] && ln -svf ".alt/${item}-default" "$HOME/.config/$item"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -11,6 +11,7 @@ from shutil import copy2
|
|||||||
|
|
||||||
# autopep8: off
|
# autopep8: off
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
gi.require_version("Notify", "0.7")
|
gi.require_version("Notify", "0.7")
|
||||||
from gi.repository import Notify, GLib
|
from gi.repository import Notify, GLib
|
||||||
# autopep8: on
|
# autopep8: on
|
||||||
@@ -50,9 +51,9 @@ def take_screenshot(filepath: Path, typeStr: str):
|
|||||||
wait_until_file_exists(filepath)
|
wait_until_file_exists(filepath)
|
||||||
elif "niri" in currentDesktop:
|
elif "niri" in currentDesktop:
|
||||||
cmd = {
|
cmd = {
|
||||||
ScreenshotType.FULL: f"niri msg action screenshot-screen",
|
ScreenshotType.FULL: "niri msg action screenshot-screen",
|
||||||
ScreenshotType.AREA: f"niri msg action screenshot",
|
ScreenshotType.AREA: "niri msg action screenshot",
|
||||||
ScreenshotType.WINDOW: f"niri msg action screenshot-window",
|
ScreenshotType.WINDOW: "niri msg action screenshot-window",
|
||||||
}
|
}
|
||||||
niriScreenshotPath = SCREENSHOT_DIR / ".niri_screenshot.png"
|
niriScreenshotPath = SCREENSHOT_DIR / ".niri_screenshot.png"
|
||||||
if niriScreenshotPath.exists():
|
if niriScreenshotPath.exists():
|
||||||
@@ -77,6 +78,7 @@ def take_screenshot(filepath: Path, typeStr: str):
|
|||||||
|
|
||||||
def edit_screenshot(filepath: Path):
|
def edit_screenshot(filepath: Path):
|
||||||
subprocess.run(f"gradia {filepath}", shell=True)
|
subprocess.run(f"gradia {filepath}", shell=True)
|
||||||
|
# subprocess.run(f"spectacle -l --edit-existing {filepath}", shell=True)
|
||||||
|
|
||||||
|
|
||||||
def file_name(dir: Path, prefix="screenshot", ext=".png"):
|
def file_name(dir: Path, prefix="screenshot", ext=".png"):
|
||||||
@@ -131,7 +133,7 @@ if __name__ == "__main__":
|
|||||||
n = Notify.Notification.new(
|
n = Notify.Notification.new(
|
||||||
"Screenshot taken",
|
"Screenshot taken",
|
||||||
# Mako doesn't have action buttons displayed with notification cards,
|
# Mako doesn't have action buttons displayed with notification cards,
|
||||||
"Click to edit"
|
"Click to edit",
|
||||||
)
|
)
|
||||||
n.add_action(
|
n.add_action(
|
||||||
# so default action is used here, which will be triggered on clicking the notification card
|
# so default action is used here, which will be triggered on clicking the notification card
|
||||||
@@ -139,7 +141,7 @@ if __name__ == "__main__":
|
|||||||
# But for my (or to be precise, Noctalia's) quickshell config, buttons will be displayed with label
|
# But for my (or to be precise, Noctalia's) quickshell config, buttons will be displayed with label
|
||||||
"Open in Editor",
|
"Open in Editor",
|
||||||
edit_callback,
|
edit_callback,
|
||||||
None
|
None,
|
||||||
)
|
)
|
||||||
|
|
||||||
# set timeout for close_callback
|
# set timeout for close_callback
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1 @@
|
|||||||
|
--target=~
|
||||||
Submodule config/wallpaper/Pictures/backgrounds updated: 8ac0f58922...cbe612b64b.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1 @@
|
|||||||
|
.alt/wlogout-default
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
.alt/wlogout-niri
|
||||||
Reference in new issue
Block a user