diff --git a/.kvantum/apply-color b/.kvantum/apply-color new file mode 100755 index 0000000..fa750b3 --- /dev/null +++ b/.kvantum/apply-color @@ -0,0 +1,11 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +kvantummanager --set catppuccin-mocha-"$colorName" || { + log_error "Failed to set kvantum theme to catppuccin-mocha-${colorName}" + exit 1 +} + +log_success "kvantum" \ No newline at end of file diff --git a/.scripts/change-colortheme b/.scripts/change-colortheme index bff32ae..c715dc4 100755 --- a/.scripts/change-colortheme +++ b/.scripts/change-colortheme @@ -1,12 +1,14 @@ #!/usr/bin/env python3 ''' +refer to `find $dotfiles_path -type f -iname "apply-color"` for implementations. + - kvantum: kvantummanager --set catppuccin-mocha-"$flavor" (a kvantum window will pop out if such theme is not installed) - nwg-look: edit $HOME/.local/share/nwg-look/gsettings nwg-look -a - nwg-look & manually confirm + nwg-look -> confirm (not implemented yet) - eww: edit $HOME/.config/eww/eww.scss eww reload @@ -46,8 +48,7 @@ import argparse from typing import Callable -FLAVOR_NAME_PLACEHOLDER = "" -FLAVOR_HEX_PLACEHOLDER = "" +SCRIPT_NAME = "apply-color" PALETTES = { @@ -69,178 +70,23 @@ PALETTES = { }, } -CURRENT_DIR = Path(__file__).resolve().parent.resolve() +CONFIG_DIR = Path(__file__).resolve().parent.resolve().parent.resolve() -def replace_placeholders(file_path: Path, palette: dict[str, str], flavor: str): - print(f"Applying flavor {flavor} to {file_path}") - - if not file_path.exists(): - print(f"File {file_path} does not exist.") - raise FileNotFoundError(f"File {file_path} does not exist.") - - with file_path.open('r') as file: - content = file.read() - - content = content.replace(FLAVOR_NAME_PLACEHOLDER, flavor) - content = content.replace(FLAVOR_HEX_PLACEHOLDER, palette[flavor]) - - with file_path.open('w') as file: - file.write(content) - - -def copy_template(src: Path, dist_dir: Path | None) -> Path: - if dist_dir is None: - dist_dir = src.parent - - dist = dist_dir / src.name.removesuffix('.template') - - print(f"Copying {src} to {dist}") - - if not dist_dir.exists(): - print(f"Destination directory {dist_dir} does not exist.") - raise FileNotFoundError(f"Destination directory {dist_dir} does not exist.") - if not dist_dir.is_dir(): - print(f"Destination {dist_dir} is not a directory.") - raise NotADirectoryError(f"Destination {dist_dir} is not a directory.") - if not src.exists(): - print(f"Source file {src} does not exist.") - raise FileNotFoundError(f"Source file {src} does not exist.") - - shutil.copyfile(src, dist, follow_symlinks=True) - return dist +def get_script_list() -> list[Path]: + scripts = [] + # find -type f -iname "apply-color" $configDir + for item in CONFIG_DIR.rglob(SCRIPT_NAME): + if item.is_file() and os.access(item, os.X_OK): + scripts.append(item.resolve()) + print(f"Found {len(scripts)} scripts to apply themes") + return scripts def hex2rgb(hex_color: str) -> tuple[int, int, int]: return tuple(int(hex_color[i:i + 2], 16) for i in (0, 2, 4)) # type: ignore -def _change_kvantum(_, flavor): - os.system(f'kvantummanager --set catppuccin-mocha-{flavor}') - # execute twice to ensure the theme is installed AND applied - os.system(f'kvantummanager --set catppuccin-mocha-{flavor}') - - -def _change_nwglook(_, flavor): - lines: list[str] = [] - with Path.home().joinpath('.local', 'share', 'nwg-look', 'gsettings').open('r') as file: - content = file.read() - lines = content.splitlines() - for i, line in enumerate(lines): - if line.startswith('gtk-theme'): - lines[i] = f'gtk-theme=catppuccin-mocha-{flavor}-standard+default' - break - else: - lines.append(f'gtk-theme=catppuccin-mocha-{flavor}-standard+default') - - with Path.home().joinpath('.local', 'share', 'nwg-look', 'gsettings').open('w') as file: - file.write('\n'.join(lines)) - - os.system('nwg-look -a') - os.system('nwg-look') - - -def _change_eww(palette: dict[str, str], flavor: str): - eww_template = Path.home().joinpath('.config', 'eww', 'eww.scss.template') - eww_dist = copy_template(eww_template, Path.home().joinpath('.config', 'eww')) - replace_placeholders(eww_dist, palette, flavor) - - os.system('eww reload') - - -def _change_hypr(palette: dict[str, str], flavor: str): - hypr_template = Path.home().joinpath('.config', 'hypr', 'hyprland', 'colors.conf.template') - hypr_dist = copy_template(hypr_template, Path.home().joinpath('.config', 'hypr', 'hyprland')) - replace_placeholders(hypr_dist, palette, flavor) - - os.system('hyprctl reload') - - -def _change_rofi(palette: dict[str, str], flavor: str): - rofi_template = Path.home().joinpath('.config', 'rofi', 'config.rasi.template') - rofi_dist = copy_template(rofi_template, Path.home().joinpath('.config', 'rofi')) - replace_placeholders(rofi_dist, palette, flavor) - - -def _change_waybar(palette: dict[str, str], flavor: str): - waybar_template = Path.home().joinpath('.config', 'waybar', 'style.css.template') - waybar_dist = copy_template(waybar_template, Path.home().joinpath('.config', 'waybar')) - replace_placeholders(waybar_dist, palette, flavor) - os.system('waybar-toggle restart') - - -def _change_ohmyposh(palette: dict[str, str], flavor: str): - posh_template = Path.home().joinpath('.config', 'posh_theme.omp.json.template') - posh_dist = copy_template(posh_template, Path.home().joinpath('.config')) - replace_placeholders(posh_dist, palette, flavor) - - -def _change_fastfetch(palette: dict[str, str], flavor: str): - fetch_template = Path.home().joinpath('.config', 'fish', 'post.d', 'fetch.fish.template') - fetch_dist = copy_template(fetch_template, Path.home().joinpath('.config', 'fish', 'post.d')) - replace_placeholders(fetch_dist, palette, flavor) - - -def _change_mako(palette: dict[str, str], flavor: str): - mako_template = Path.home().joinpath('.config', 'mako', 'config.template') - mako_dist = copy_template(mako_template, Path.home().joinpath('.config', 'mako')) - replace_placeholders(mako_dist, palette, flavor) - - os.system('makoctl reload') - - -def _change_yazi(_, flavor): - yazi_template = CURRENT_DIR / '..' / '.yazi-themes' / f'catppuccin-mocha-{flavor}.toml' - yazi_dist = Path.home().joinpath('.config', 'yazi', 'theme.toml') - shutil.copyfile(yazi_template, yazi_dist, follow_symlinks=True) - print(f"Copied {yazi_template} to {yazi_dist}") - - -def _change_wlogout(palette: dict[str, str], flavor: str): - wlogout_template = Path.home().joinpath('.config', 'wlogout', 'style.css.template') - wlogout_dist = copy_template(wlogout_template, Path.home().joinpath('.config', 'wlogout')) - replace_placeholders(wlogout_dist, palette, flavor) - - for icon_template in Path.home().joinpath('.config', 'wlogout', 'icons').glob('*.svg.template'): - icon_dist = copy_template(icon_template, Path.home().joinpath('.config', 'wlogout', 'icons')) - replace_placeholders(icon_dist, palette, flavor) - - -def _change_fuzzel(palette: dict[str, str], flavor: str): - fuzzel_template = Path.home().joinpath('.config', 'fuzzel', 'fuzzel.ini.template') - fuzzel_dist = copy_template(fuzzel_template, Path.home().joinpath('.config', 'fuzzel')) - replace_placeholders(fuzzel_dist, palette, flavor) - - -def _change_niri(palette: dict[str, str], flavor: str): - niri_template = Path.home().joinpath('.config', 'niri', 'config.kdl.template') - niri_dist = copy_template(niri_template, Path.home().joinpath('.config', 'niri')) - replace_placeholders(niri_dist, palette, flavor) - - -def _change_quickshell(palette: dict[str, str], flavor: str): - hex_color = palette[flavor] - os.system(f'qs ipc call colors setPrimary {hex_color}') - - -apply_theme_funcs: dict[str, Callable[[dict[str, str], str], None]] = { - 'kvantum': _change_kvantum, - 'nwg-look': _change_nwglook, - 'eww': _change_eww, - 'hypr': _change_hypr, - 'rofi': _change_rofi, - 'waybar': _change_waybar, - 'oh-my-posh': _change_ohmyposh, - 'fastfetch': _change_fastfetch, - 'mako': _change_mako, - 'yazi': _change_yazi, - 'wlogout': _change_wlogout, - 'fuzzel': _change_fuzzel, - 'niri': _change_niri, - 'quickshell': _change_quickshell, -} - - def extract_color(image_path: str) -> str: from colorthief import ColorThief return "#{:02x}{:02x}{:02x}".format(*ColorThief(image_path).get_color(quality=10)) @@ -342,7 +188,10 @@ def main(): parser.add_argument('-f', '--flavor', type=str, help="Flavor to apply") parser.add_argument('-c', '--color', type=str, help="Color to match from the palette") parser.add_argument('arguments', nargs='*', - help="List of applications to change the color theme of, or !app to exclude an application. Available apps: " + ', '.join(apply_theme_funcs.keys())) + help="Any number of 'pattern' and '!pattern'. " + f"Initially all scripts with name {SCRIPT_NAME} under {CONFIG_DIR} (recursively) will be considered. " + f"If at least one pattern is given, only scripts that has any of the patterns in their path will be executed. " + "If a pattern is prefixed with '!', scripts that have that pattern in their path will be excluded.") arguments = parser.parse_args() @@ -371,51 +220,54 @@ def main(): flavor = pick_flavor(palette) return flavor - def parse_apps() -> list[str]: - apps = set() - if not arguments.arguments: - apps = set(apply_theme_funcs.keys()) - else: - allExclude = True - for arg in arguments.arguments: - if arg[0] == '!': - continue - allExclude = False - if arg not in apply_theme_funcs: - print(f"Unknown app: {arg}. Available apps: {', '.join(apply_theme_funcs.keys())}") - sys.exit(1) - apps.add(arg) - - # If all arguments are exclusions, start with all apps - if allExclude: - apps = set(apply_theme_funcs.keys()) - + def parse_apps() -> tuple[set[str], set[str]]: + includes = set() + excludes = set() for arg in arguments.arguments: - if arg[0] == '!': - print(f"Excluding app: {arg[1:]}") - app = arg[1:] - if app not in apply_theme_funcs: - print(f"Unknown app to exclude: {app}. Available apps: {', '.join(apply_theme_funcs.keys())}") - sys.exit(1) - apps.discard(app) - - return list(apps) + if arg.startswith('!'): + excludes.add(arg[1:]) + else: + includes.add(arg) + return includes, excludes palette_name = parse_palette_name() palette = PALETTES[palette_name] flavor = parse_flavor(palette) - apps = parse_apps() + includes, excludes = parse_apps() + scripts = get_script_list() - for app in apps: - func = apply_theme_funcs[app] - try: - print(f"Changing color theme of {app} to flavor {flavor}...") - func(palette, flavor) - print("Success!\n") - except Exception as e: - print(f"Error while tweaking {app}: {e}") + filteredScripts = [] + if includes: + print(f"Including only: {', '.join(includes)}") - os.system(f'notify-send -a "change-colortheme" "Color theme changed" "Palette: {palette_name}\nFlavor: {flavor}"') + # for script in scripts: + # for include in includes: + # if include in str(script): + # filteredScripts.append(script) + # break + filteredScripts = [ + script for script in scripts + if any(include in str(script) for include in includes) + ] + else: + filteredScripts = scripts + + if excludes: + print(f"Excluding: {', '.join(excludes)}") + filteredScripts = [ + script for script in filteredScripts + if not any(exclude in str(script) for exclude in excludes) + ] + + print(f"Applying flavor '{flavor}' using {len(filteredScripts)} scripts") + + for script in filteredScripts: + print(f"Running script: {script}") + os.system(f'"{script}" {palette_name} {flavor} {palette[flavor]}') + print("") + + os.system( + f'notify-send -a "change-colortheme" "Colortheme Changed" "Palette: {palette_name};\nFlavor: {flavor};\nApplied to {len(filteredScripts)} applications."') if __name__ == "__main__": diff --git a/.scripts/change-wallpaper b/.scripts/change-wallpaper index 6364f73..04353fb 100755 --- a/.scripts/change-wallpaper +++ b/.scripts/change-wallpaper @@ -80,13 +80,13 @@ if [ "$XDG_CURRENT_DESKTOP" = "Hyprland" ]; then notify-send -a "change-wallpaper" "Wallpaper Changed" "$image" -i "$image_copied" - change-colortheme -i "$image_copied" !quickshell !nwg-look || exit 1 + change-colortheme -i "$image_copied" || exit 1 elif [ "$XDG_CURRENT_DESKTOP" = "niri" ]; then swww img -n background "$image_copied" --transition-type fade --transition-duration 2 > /dev/null 2> /dev/null notify-send -a "change-wallpaper" "Wallpaper Changed" "$image" -i "$image_copied" - change-colortheme -i "$image_copied" !waybar !eww !mako !nwg-look || exit 1 + change-colortheme -i "$image_copied" || exit 1 else echo "Unsupported desktop environment: $XDG_CURRENT_DESKTOP" exit 1 diff --git a/.scripts/lyrics-widgets b/.scripts/lyrics-widgets index a6a0eba..685804a 100755 --- a/.scripts/lyrics-widgets +++ b/.scripts/lyrics-widgets @@ -11,7 +11,7 @@ if [ -z "$LYRICS" ] && [ -z "$LYRICS_SINGLE" ]; then elif [ -n "$LYRICS" ] && [ -z "$LYRICS_SINGLE" ]; then eww close lyrics # if waybar is running, open lyrics-single - if pgrep -x "waybar" > /dev/null; then + if pgrep -x "waybar" -u "$USER" > /dev/null; then sleep 0.5 eww open lyrics-single fi diff --git a/.scripts/record-script b/.scripts/record-script index dea4209..fa53b9c 100755 --- a/.scripts/record-script +++ b/.scripts/record-script @@ -41,9 +41,9 @@ done mkdir -p "$(xdg-user-dir VIDEOS)" cd "$(xdg-user-dir VIDEOS)" || exit -if pgrep wf-recorder > /dev/null; then +if pgrep -x wf-recorder -u "$USER" > /dev/null; then notify-send "Recording Stopped" "Stopped" -a 'record-script' & - pkill wf-recorder & + pkill -x wf-recorder -u "$USER" else notify-send "Starting recording" 'recording_'"$(getdate)"'.mkv' -a 'record-script' if [[ "$1" == "--sound" ]]; then diff --git a/.scripts/sl-wrap b/.scripts/sl-wrap index 81e10fd..e6d3e27 100755 --- a/.scripts/sl-wrap +++ b/.scripts/sl-wrap @@ -1,4 +1,4 @@ #!/bin/sh -pgrep -f spotify-lyrics && (killall spotify-lyrics || exit 1) +pgrep -f spotify-lyrics -u "$USER" && (killall spotify-lyrics -u "$USER" || exit 1) spotify-lyrics "$@" diff --git a/.scripts/wallpaper-daemon b/.scripts/wallpaper-daemon index 6b72e0c..4a4eb68 100755 --- a/.scripts/wallpaper-daemon +++ b/.scripts/wallpaper-daemon @@ -6,7 +6,7 @@ import subprocess import threading from sys import exit from time import sleep -from os import environ +from os import environ, getuid from pathlib import Path from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler @@ -66,7 +66,7 @@ def swwwLoadImg(namespace: str, wallpaper: Path): def swwwStartDaemon(namespace: str): # Check if daemon is already running - cmd = ["pgrep", "-f", f"swww daemon -n {namespace}"] + cmd = ["pgrep", "-f", f"swww daemon -n {namespace}"], "-u", str(getuid()) try: output = subprocess.check_output(cmd, text=True) pids = output.strip().splitlines() diff --git a/.scripts/waybar-toggle b/.scripts/waybar-toggle index 91c80dd..63982b9 100755 --- a/.scripts/waybar-toggle +++ b/.scripts/waybar-toggle @@ -15,7 +15,7 @@ function close() { function open() { # the system tray will not work with kded6 started if killall -q -9 "kded6"; then - while pgrep -x "kded6" >/dev/null; do + while pgrep -u "$USER" -x "kded6" >/dev/null; do sleep 0.2 done fi @@ -29,13 +29,13 @@ function open() { if [ "$1" = "restart" ]; then close - while pgrep -x "waybar" >/dev/null; do + while pgrep -u "$USER" -x "waybar" >/dev/null; do sleep 0.2 done open -elif pgrep -x "waybar" >/dev/null; then +elif pgrep -u "$USER" -x "waybar" >/dev/null; then close -elif ! pgrep -x "waybar" >/dev/null; then +elif ! pgrep -u "$USER" -x "waybar" >/dev/null; then open else echo "Usage: $0 [restart]" diff --git a/.utils/apply-color-parse-arg b/.utils/apply-color-parse-arg new file mode 100644 index 0000000..f3eb458 --- /dev/null +++ b/.utils/apply-color-parse-arg @@ -0,0 +1,32 @@ +# snippet to parse args in apply-color scripts + +[ -z "$1" ] && exit 1 +palette="$1" +[ -z "$2" ] && exit 1 +colorName="$2" +[ -z "$3" ] && exit 1 +colorHex="$3" + +function log_error { + printf "\033[0;31mError:\033[0m $1\n" >&2 +} + +function log_info { + printf "\033[0;32mInfo:\033[0m $1\n" >&2 +} + + +# remove leading '#' if present +if [[ $colorHex == \#* ]]; then + colorHex="${colorHex#\#}" +fi + +# check if hex +if ! [[ $colorHex =~ ^[0-9A-Fa-f]{6}$ ]]; then + log_error "Invalid color hex: $colorHex" + exit 1 +fi + +function log_success { + log_info "Applied primary color ${colorName} (${colorHex}) to \033[1;34m$1\033[0m" +} \ No newline at end of file diff --git a/eww/apply-color b/eww/apply-color new file mode 100755 index 0000000..66b15ee --- /dev/null +++ b/eww/apply-color @@ -0,0 +1,18 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +file="$path"/eww.scss + +sed -i "s|^\$border: #[0-9a-fA-F]\{6\};\$|\$border: #${colorHex};|" "$file" || { + log_error "Failed to edit ${file}" + exit 1 +} + +pgrep -x eww >/dev/null -u "$USER" && eww reload || { + log_error "Failed to reload eww, is it running?" + exit 1 +} + +log_success "eww" \ No newline at end of file diff --git a/eww/eww.scss.template b/eww/eww.scss.template deleted file mode 100644 index 8cd7452..0000000 --- a/eww/eww.scss.template +++ /dev/null @@ -1,23 +0,0 @@ -/** Colors *******************************************/ -$bg: #1e1e2e; -$bg-alt: #181825; -$fg: #cdd6f4; -$fg-alt: #a6adc8; -$red: #f38ba8; -$green: #a6e3a1; -$yellow: #f9e2af; -$orange: #fab387; -$blue: #89b4fa; -$purple: #cba6f7; -$cyan: #89dceb; -$gray: #585b70; -$gray-alt: #292a3c; -$lavender: #b4befe; -$sapphire: #74c7ec; -$teal: #94e2d5; -$peach: #fab387; - -$border: #; - -@import './Main/eww.scss'; -@import './Lyrics/eww.scss'; diff --git a/fish/apply-color b/fish/apply-color new file mode 100755 index 0000000..5e1f50c --- /dev/null +++ b/fish/apply-color @@ -0,0 +1,24 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +file="$path"/post.d/fetch.fish + +sed -i 's/^\( set -g fetch_color "\)#\([0-9a-fA-F]\{6\}\)"/\1#'"${colorHex}"'"/' "$file" || { + log_error "Failed to edit ${file}" + exit 1 +} + +log_success "fastfetch" + +# Also apply to omp in here + +file="$path"/../posh_theme.omp.json + +sed -i 's/\("foreground":[[:space:]]*"\)#\([0-9a-fA-F]\{6\}\)"/\1#'"${colorHex}"'"/g' "$file" || { + log_error "Failed to edit ${file}" + exit 1 +} + +log_success "oh-my-posh" \ No newline at end of file diff --git a/fish/post.d/fetch.fish.template b/fish/post.d/fetch.fish.template deleted file mode 100644 index 8e82150..0000000 --- a/fish/post.d/fetch.fish.template +++ /dev/null @@ -1,38 +0,0 @@ -if not set -q fetch_logo_type - set -g fetch_logo_type "auto" -end - -if not set -q fetch_color - set -g fetch_color "#" -end - -if test "$fetch_logo_type" = "symbols" - set -g fetch_args "--logo-type raw --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/42x.symbols\" --color \"$fetch_color\"" - set -g fetch_args_brief "--logo-type raw --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/28x.symbols\" --color \"$fetch_color\"" -else if test "$fetch_logo_type" = "logo" - set -g fetch_args "--logo-type builtin" - set -g fetch_args_brief "--logo-type small" -else if test "$fetch_logo_type" = "sixel" - set -g fetch_args "--logo-type raw --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/42x.sixel\" --color \"$fetch_color\"" - set -g fetch_args_brief "--logo-type raw --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/28x.sixel\" --color \"$fetch_color\"" -else # "kitty" or "auto" and others - set -g fetch_args "--logo-type $fetch_logo_type --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/ros.png\" --color \"$fetch_color\"" - set -g fetch_args_brief "--logo-type $fetch_logo_type --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/ros.png\" --color \"$fetch_color\"" -end - -if type -q fastfetch - alias ff="fastfetch -c $HOME/.config/fastfetch/config.jsonc $fetch_args" - - if test -f "$HOME/.config/fastfetch/brief.jsonc" - alias ff-brief="fastfetch -c $HOME/.config/fastfetch/brief.jsonc $fetch_args_brief" - else - alias ff-brief=ff - end -end - -# add 'set -g no_fetch' somewhere other than post.d to disable fetching -if not set -q no_fetch - if type -q ff-brief - ff-brief - end -end diff --git a/fuzzel/apply-color b/fuzzel/apply-color new file mode 100755 index 0000000..9036a8e --- /dev/null +++ b/fuzzel/apply-color @@ -0,0 +1,22 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +file="$path"/fuzzel.ini +entries="match selection-match border" + +if pgrep -x "fuzzel" -u "$USER" > /dev/null; then + pkill -x fuzzel || log_error "Failed to kill fuzzel process" + # and move on +fi + +for entry in $entries; do + # Not very sure if alpha channels are neccessary here, but just in case + sed -i -E "s/^($entry\s*=\s*)([0-9A-Fa-f]{6})([0-9A-Fa-f]{0,2})/\1${colorHex}\3/" "$file" || { + log_error "Failed to edit ${file} for entry ${entry}" + exit 1 + } +done + +log_success "fuzzel" \ No newline at end of file diff --git a/fuzzel/fuzzel.ini.template b/fuzzel/fuzzel.ini.template deleted file mode 100755 index 07c5d02..0000000 --- a/fuzzel/fuzzel.ini.template +++ /dev/null @@ -1,24 +0,0 @@ -terminal=kitty -e -prompt=">> " -layer=overlay - -[colors] -background=1e1e2edd -text=cdd6f4ff -prompt=bac2deff -placeholder=7f849cff -input=cdd6f4ff -match=ff -selection=585b70ff -selection-text=cdd6f4ff -selection-match=ff -counter=7f849cff -border=ff - - -[border] -radius=17 -width=2 - -[dmenu] -exit-immediately-if-empty=yes diff --git a/hypr/apply-color b/hypr/apply-color new file mode 100755 index 0000000..9ae3cd9 --- /dev/null +++ b/hypr/apply-color @@ -0,0 +1,25 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +file="$path"/hyprland/colors.conf + +sed -i -E "s/^(\s*col\.active_border\s*=\s*rgba\()([0-9A-Fa-f]{6})([0-9A-Fa-f]{2}\))$/\1${colorHex}\3/" "$file" || { + log_error "Failed to edit ${file} for entry col.active_border" + exit 1 +} + +sed -i -E "s/^(\s*col\.inactive_border\s*=\s*rgba\()([0-9A-Fa-f]{6})([0-9A-Fa-f]{2}\))$/\1${colorHex}\3/" "$file" || { + log_error "Failed to edit ${file} for entry col.active_border" + exit 1 +} + +if pgrep -x "hyprland" -u "$USER" > /dev/null; then + hyprctl reload || { + log_error "Failed to reload Hyprland" + exit 1 + } +fi + +log_success "hyprland" \ No newline at end of file diff --git a/hypr/fix.sh.noeffect b/hypr/fix.sh.noeffect deleted file mode 100755 index 58dd6fc..0000000 --- a/hypr/fix.sh.noeffect +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -sleep 4 -killall -e xdg-desktop-portal-hyprland -killall xdg-desktop-portal -/usr/lib/xdg-desktop-portal-hyprland & -sleep 4 -/usr/lib/xdg-desktop-portal & diff --git a/hypr/hyprland/colors.conf b/hypr/hyprland/colors.conf index 581c7a3..99cfaa8 100755 --- a/hypr/hyprland/colors.conf +++ b/hypr/hyprland/colors.conf @@ -1,7 +1,7 @@ # exec = export SLURP_ARGS='-d -c BFE9F8BB -b 214C5844 -s 00000000' general { - col.active_border = rgba(89b4faFF) + col.active_border = rgba(89b4faff) col.inactive_border = rgba(89b4fa80) } diff --git a/hypr/hyprland/colors.conf.template b/hypr/hyprland/colors.conf.template deleted file mode 100755 index 485f199..0000000 --- a/hypr/hyprland/colors.conf.template +++ /dev/null @@ -1,12 +0,0 @@ -# exec = export SLURP_ARGS='-d -c BFE9F8BB -b 214C5844 -s 00000000' - -general { - col.active_border = rgba(FF) - col.inactive_border = rgba(80) -} - -misc { - background_color = rgba(181825FF) -} - -windowrulev2 = bordercolor rgba(00DCE3AA) rgba(00DCE377),pinned:1 \ No newline at end of file diff --git a/mako/apply-color b/mako/apply-color new file mode 100755 index 0000000..5202eba --- /dev/null +++ b/mako/apply-color @@ -0,0 +1,21 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +file="$path"/config +entry="border-color" + +sed -i -E "0,/^($entry\s*=\s*#)([0-9A-Fa-f]{6})/s//\1${colorHex}/" "$file" || { + log_error "Failed to edit ${file} for entry ${entry}" + exit 1 +} + +if pgrep -x "mako" -u "$USER" > /dev/null; then + makoctl reload || { + log_error "Failed to reload mako" + exit 1 + } +fi + +log_success "mako" \ No newline at end of file diff --git a/mako/config.template b/mako/config.template deleted file mode 100644 index 1e1a814..0000000 --- a/mako/config.template +++ /dev/null @@ -1,37 +0,0 @@ -max-visible=10 -layer=top -font=Noto Sans 12 -border-radius=12 -max-icon-size=48 -default-timeout=5000 -anchor=top-right -margin=20 - -background-color=#1e1e2e -text-color=#cdd6f4 -border-color=# -progress-color=over #313244 - -[urgency=high] -border-color=#fab387 - -[app-name=wp-vol] -layer=overlay -history=0 -anchor=top-center -# Group all volume notifications together -group-by=app-name -# Hide the group-index -format=%s\n%b - -[app-name=volume group-index=0] -# Only show last notification -invisible=0 - -[app-name=spotify-lyrics] -history=0 -group-by=app-name -format=%s\n%b - -[app-name=spotify-lyrics group-index=0] -invisible=0 \ No newline at end of file diff --git a/niri/apply-color b/niri/apply-color new file mode 100755 index 0000000..7964706 --- /dev/null +++ b/niri/apply-color @@ -0,0 +1,13 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +file="$path"/config.kdl + +sed -i -E "s/^(\s*active-color\s+\"#)([0-9A-Fa-f]{6})(\")/\1${colorHex}\3/" "$file" || { + log_error "Failed to edit ${file}" + exit 1 +} + +log_success "niri" \ No newline at end of file diff --git a/niri/config.kdl.template b/niri/config.kdl.template deleted file mode 100644 index 87a7610..0000000 --- a/niri/config.kdl.template +++ /dev/null @@ -1,429 +0,0 @@ -/************************Input************************/ - -input { - keyboard { - xkb { - layout "de" - } - - numlock - } - - touchpad { - tap - natural-scroll - scroll-method "two-finger" - } - - mouse { - accel-speed 0.25 - } - - trackpoint { - off - } - - // Make the mouse warp to the center of newly focused windows. - warp-mouse-to-focus - - // Focus windows and outputs automatically when moving the mouse into them. - focus-follows-mouse max-scroll-amount="99%" -} - -/************************Output************************/ - -output "eDP-1" { - mode "2560x1600@240" - scale 1.25 - background-color "#1e1e2e" - backdrop-color "#1e1e2e" -} - -output "eDP-2" { - mode "2560x1600@240" - scale 1.25 - background-color "#1e1e2e" - backdrop-color "#1e1e2e" -} - -/************************Layout************************/ - -layout { - gaps 0 - - center-focused-column "never" - - preset-column-widths { - proportion 0.3 - proportion 0.5 - proportion 0.7 - } - - preset-window-heights { - proportion 0.5 - proportion 0.75 - proportion 1.0 - } - - default-column-width { proportion 0.7; } - - focus-ring { - width 2 - active-color "#" - inactive-color "#1e1e2e" - } - - border { - off - } - - shadow { - on - - softness 30 - spread 5 - offset x=0 y=5 - color "#0007" - } - - struts { - top 2 - right 2 - bottom 3 - left 2 - } - - background-color "#1e1e2e" -} - -// Disable the "Important Hotkeys" pop-up at startup. -hotkey-overlay { - skip-at-startup -} - -prefer-no-csd - -animations { - // off - // slowdown 3.0 -} - -layer-rule { - match namespace="^swww-daemonbackdrop$" - place-within-backdrop true - -} - - -/************************Autostart************************/ - -// Switch configs -spawn-sh-at-startup "config-switch niri" - -// Idle -spawn-sh-at-startup "hypridle" - - -// Wallpaper -spawn-at-startup "wallpaper-daemon" - -// Not necessary maybe ... -spawn-at-startup "fcitx5" - -// Core -spawn-at-startup "blueman-applet" -spawn-at-startup "nm-applet" -spawn-sh-at-startup "gnome-keyring-daemon --start --components=secrets" -spawn-at-startup "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1" - -// Clipboard history -spawn-sh-at-startup "wl-paste --type text --watch cliphist store" -spawn-sh-at-startup "wl-paste --type image --watch cliphist store" - -// Logitech -spawn-sh-at-startup "solaar -w hide" - -// Application associations -spawn-at-startup "kbuildsycoca6" - -// Some other heavy apps -spawn-at-startup "sunshine" - -// Quickshell must start after hypridle, -// otherwise Firefox cannot block idle when playing media -spawn-at-startup "quickshell" - -/************************Envs************************/ - -environment { - // Input Method - QT_IM_MODULE "fcitx" - XMODIFIERS "@im=fcitx" - SDL_IM_MODULE "fcitx" - GLFW_IM_MODULE "ibus" - INPUT_METHOD "fcitx" - - // Themes - QT_QPA_PLATFORM "wayland" - QT_QPA_PLATFORMTHEME "kde" - QT_STYLE_OVERRIDE "Kvantum" - - // Nvidia - LIBVA_DRIVER_NAME "nvidia" - __GLX_VENDOR_LIBRARY_NAME "nvidia" - NVD_BACKEND "nvidia" - - // Others - XCURSOR_SIZE "24" - ELECTRON_OZONE_PLATFORM_HINT "wayland" -} - -/************************Rules************************/ - -// Picture-in-Picture -window-rule { - match title="^([Pp]icture[-\\s]?[Ii]n[-\\s]?[Pp]icture)(.*)$" - open-floating true -} - -// Dialog windows -window-rule { - match title="^(Open File)(.*)$" - match title="^(Select a File)(.*)$" - match title="^(Choose wallpaper)(.*)$" - match title="^(Open Folder)(.*)$" - match title="^(Save As)(.*)$" - match title="^(Library)(.*)$" - match title="^(File Upload)(.*)$" - open-floating true -} - -// FLoating terminal -window-rule { - match app-id="com.mitchellh.ghostty" - open-floating true - default-column-width { proportion 0.5; } -} - -// Normal terminal -window-rule { - match app-id="kitty" - default-column-width { proportion 0.5; } -} - -// Scrcpy -window-rule { - match app-id="scrcpy" - default-column-width { proportion 0.3; } -} - -// Editor -window-rule { - match app-id="org.gnome.TextEditor" - default-column-width { proportion 0.3; } -} - -// Other floating -window-rule { - match app-id="blueberry" - match app-id="blueman-manager" - match app-id="pavucontrol" - match app-id="org.pulseaudio.pavucontrol" - match app-id="Waydroid" - match app-id="org.kde.kcalc" - match app-id="org.kde.kalk" - match app-id="org.gnome.NautilusPreviewer" - match app-id="coin" - match app-id="wallpaper-chooser" - match app-id="be.alexandervanhee.gradia" - match title="^(图片查看器)(.*)$" // QQ - open-floating true -} - -// Block from recording -window-rule { - match app-id="thunderbird" - - block-out-from "screen-capture" -} - -// I love round corners -window-rule { - geometry-corner-radius 14 - clip-to-geometry true -} - - -/************************Others************************/ - -cursor { - xcursor-theme "Bibata-Modern-Ice" - xcursor-size 24 - hide-when-typing -} - -debug { - render-drm-device "/dev/dri/card0" -} - -screenshot-path "~/Pictures/Screenshots/.niri_screenshot.png" - -// gestures { -// hot-corners { -// off -// } -// } - -/************************Keybindings************************/ - -binds { - // Apps - Mod+C { spawn-sh "code --password-store=gnome-libsecret"; } - Mod+E { spawn "dolphin"; } - Mod+W { spawn "zen"; } - Mod+X { spawn "gnome-text-editor" "--new-window"; } - Mod+B { spawn-sh "pkill -x -n btop || ghostty -e btop"; } - Mod+T { spawn "kitty"; } - Mod+Return { spawn "kitty"; } - Mod+Shift+T { spawn "ghostty"; } - Mod+Shift+Return { spawn "ghostty"; } - Mod+Shift+W { spawn "wallpaper-chooser"; } - - // Quickshell - Mod+Space { spawn-sh "qs ipc call panels toggleControlCenter"; } - Mod+Shift+D { spawn-sh "qs ipc call panels toggleCalendar"; } - Mod+Shift+L { spawn-sh "qs ipc call lyrics toggleBarLyrics"; } - Mod+Shift+K { spawn-sh "pkill -x quickshell || quickshell"; } - Mod+I { spawn-sh "qs ipc call idleInhibitor toggleInhibitor"; } - Mod+Alt+R { spawn-sh "qs ipc call recording startOrStopRecording"; } - - // Rofi - Mod+D { spawn-sh "pkill -x rofi || rofi -show run"; } - Alt+Space { spawn-sh "pkill -x rofi || rofi -show drun"; } - - // Actions - Mod+V { spawn-sh "pkill -x rofi || rofi-cliphist"; } - Mod+Period { spawn-sh "pkill -x rofi || rofi-emoji"; } - Ctrl+Alt+Delete { spawn-sh "pkill -x wlogout || wlogout -p layer-shell"; } - Print { spawn-sh "screenshot full"; } - Mod+Shift+S { spawn-sh "screenshot area"; } - Mod+Ctrl+Shift+S { spawn-sh "screenshot window"; } - Mod+Shift+C { spawn-sh "hyprpicker -a"; } - - // Session - Mod+L { spawn-sh "loginctl lock-session"; } - - // Media - XF86AudioRaiseVolume allow-when-locked=true { spawn-sh "wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+"; } - XF86AudioLowerVolume allow-when-locked=true { spawn-sh "wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%-"; } - XF86AudioMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; } - XF86AudioMicMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; } - XF86AudioPlay allow-when-locked=true { spawn-sh "playerctl play-pause"; } - XF86AudioPause allow-when-locked=true { spawn-sh "playerctl play-pause"; } - XF86AudioNext allow-when-locked=true { spawn-sh "playerctl next"; } - XF86AudioPrev allow-when-locked=true { spawn-sh "playerctl previous"; } - - // Brightness - XF86MonBrightnessUp allow-when-locked=true { spawn "set-brightness" "+10%"; } - XF86MonBrightnessDown allow-when-locked=true { spawn "set-brightness" "10%-"; } - - // Window management - Mod+Tab repeat=false { toggle-overview; } - - Mod+Q repeat=false { close-window; } - - Mod+Left { focus-column-left; } - Mod+Down { focus-window-or-workspace-down; } - Mod+Up { focus-window-or-workspace-up; } - Mod+Right { focus-column-right; } - - Mod+Shift+Left { move-column-left; } - Mod+Shift+Down { move-window-down-or-to-workspace-down; } - Mod+Shift+Up { move-window-up-or-to-workspace-up; } - Mod+Shift+Right { move-column-right; } - - Mod+Home { focus-column-first; } - Mod+End { focus-column-last; } - Mod+Shift+Home { move-column-to-first; } - Mod+Shift+End { move-column-to-last; } - - Mod+Ctrl+Left { focus-monitor-left; } - Mod+Ctrl+Down { focus-monitor-down; } - Mod+Ctrl+Up { focus-monitor-up; } - Mod+Ctrl+Right { focus-monitor-right; } - - Mod+Shift+Ctrl+Left { move-window-to-monitor-left; } - Mod+Shift+Ctrl+Down { move-window-to-monitor-down; } - Mod+Shift+Ctrl+Up { move-window-to-monitor-up; } - Mod+Shift+Ctrl+Right { move-window-to-monitor-right; } - - Mod+Page_Down { focus-workspace-down; } - Mod+Page_Up { focus-workspace-up; } - Mod+Shift+Page_Down { move-window-to-workspace-down; } - Mod+Shift+Page_Up { move-window-to-workspace-up; } - - Mod+Ctrl+Shift+Page_Down { move-workspace-down; } - Mod+Ctrl+Shift+Page_Up { move-workspace-up; } - - Mod+WheelScrollDown cooldown-ms=150 { focus-workspace-down; } - Mod+WheelScrollUp cooldown-ms=150 { focus-workspace-up; } - Mod+Shift+WheelScrollDown cooldown-ms=150 { move-column-to-workspace-down; } - Mod+Shift+WheelScrollUp cooldown-ms=150 { move-column-to-workspace-up; } - - Mod+WheelScrollRight cooldown-ms=150 { focus-column-right; } - Mod+WheelScrollLeft cooldown-ms=150 { focus-column-left; } - Mod+Shift+WheelScrollRight { move-column-right; } - Mod+Shift+WheelScrollLeft { move-column-left; } - - Mod+1 { focus-workspace 1; } - Mod+2 { focus-workspace 2; } - Mod+3 { focus-workspace 3; } - Mod+4 { focus-workspace 4; } - Mod+5 { focus-workspace 5; } - Mod+6 { focus-workspace 6; } - Mod+7 { focus-workspace 7; } - Mod+8 { focus-workspace 8; } - Mod+9 { focus-workspace 9; } - Mod+Alt+1 { move-window-to-workspace 1; } - Mod+Alt+2 { move-window-to-workspace 2; } - Mod+Alt+3 { move-window-to-workspace 3; } - Mod+Alt+4 { move-window-to-workspace 4; } - Mod+Alt+5 { move-window-to-workspace 5; } - Mod+Alt+6 { move-window-to-workspace 6; } - Mod+Alt+7 { move-window-to-workspace 7; } - Mod+Alt+8 { move-window-to-workspace 8; } - Mod+Alt+9 { move-window-to-workspace 9; } - - Mod+Alt+Left { consume-or-expel-window-left; } - Mod+Alt+Right { consume-or-expel-window-right; } - - Mod+Shift+Comma { consume-window-into-column; } - Mod+Shift+Period { expel-window-from-column; } - Mod+Shift+M { toggle-column-tabbed-display; } - - Mod+R { switch-preset-column-width; } - Mod+Shift+R { switch-preset-window-height; } - Mod+Ctrl+R { reset-window-height; } - Mod+F { maximize-column; } - Mod+Shift+F { fullscreen-window; } - Mod+Ctrl+F { expand-column-to-available-width; } - - Mod+Y { center-column; } - - Mod+Minus { set-column-width "-10%"; } - Mod+Plus { set-column-width "+10%"; } - - Mod+Shift+Minus { set-window-height "-10%"; } - Mod+Shift+Plus { set-window-height "+10%"; } - - Mod+Alt+Space { toggle-window-floating; } - Alt+Tab { switch-focus-between-floating-and-tiling; } - - Mod+Ctrl+W { toggle-column-tabbed-display; } - - Mod+Escape allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; } - - Mod+M allow-inhibiting=false { quit; } - - Mod+Shift+P { power-off-monitors; } -} diff --git a/posh_theme.omp.json b/posh_theme.omp.json index 47118f2..0e858d9 100755 --- a/posh_theme.omp.json +++ b/posh_theme.omp.json @@ -5,7 +5,7 @@ "alignment": "left", "segments": [ { - "foreground": "#74c7ec", + "foreground": "#89b4fa", "properties": { "windows": "\ue62a" }, @@ -14,19 +14,19 @@ "type": "os" }, { - "foreground": "#74c7ec", + "foreground": "#89b4fa", "style": "plain", "template": " {{.UserName}}", "type": "session" }, { - "foreground": "#74c7ec", + "foreground": "#89b4fa", "style": "plain", "template": "@{{.HostName}}", "type": "session" }, { - "foreground": "#94e2d5", + "foreground": "#89b4fa", "properties": { "folder_separator_icon": "/", "style": "letter" @@ -36,7 +36,7 @@ "type": "path" }, { - "foreground": "#a6e3a1", + "foreground": "#89b4fa", "powerline_symbol": "\ue0b1", "properties": { "branch_icon": " ", @@ -50,7 +50,7 @@ "type": "git" }, { - "foreground": "#f9e2af", + "foreground": "#89b4fa", "powerline_symbol": "\ue0b1", "template": " \ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }} ", "style": "powerline", @@ -64,13 +64,13 @@ "newline": true, "segments": [ { - "foreground": "#fab387", + "foreground": "#89b4fa", "style": "plain", "template": "\ue3bf ", "type": "root" }, { - "foreground": "#74c7ec", + "foreground": "#89b4fa", "foreground_templates": [ "{{ if gt .Code 0 }}#f38ba8{{ end }}" ], @@ -90,7 +90,7 @@ "foreground_templates": [ "{{ if gt .Code 0 }}#f38ba8{{ end }}" ], - "foreground": "#74c7ec", + "foreground": "#89b4fa", "template": "# " }, "version": 3 diff --git a/posh_theme.omp.json.template b/posh_theme.omp.json.template deleted file mode 100755 index c46620e..0000000 --- a/posh_theme.omp.json.template +++ /dev/null @@ -1,97 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", - "blocks": [ - { - "alignment": "left", - "segments": [ - { - "foreground": "#", - "properties": { - "windows": "\ue62a" - }, - "style": "plain", - "template": "{{.Icon}}", - "type": "os" - }, - { - "foreground": "#", - "style": "plain", - "template": " {{.UserName}}", - "type": "session" - }, - { - "foreground": "#", - "style": "plain", - "template": "@{{.HostName}}", - "type": "session" - }, - { - "foreground": "#94e2d5", - "properties": { - "folder_separator_icon": "/", - "style": "letter" - }, - "style": "powerline", - "template": " \uf07b {{ .Path }} ", - "type": "path" - }, - { - "foreground": "#a6e3a1", - "powerline_symbol": "\ue0b1", - "properties": { - "branch_icon": " ", - "fetch_stash_count": true, - "fetch_status": true, - "fetch_upstream_icon": true, - "fetch_worktree_count": true - }, - "style": "powerline", - "template": " {{ .UpstreamIcon }} {{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ", - "type": "git" - }, - { - "foreground": "#f9e2af", - "powerline_symbol": "\ue0b1", - "template": " \ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }} ", - "style": "powerline", - "type": "python" - } - ], - "type": "prompt" - }, - { - "alignment": "left", - "newline": true, - "segments": [ - { - "foreground": "#fab387", - "style": "plain", - "template": "\ue3bf ", - "type": "root" - }, - { - "foreground": "#", - "foreground_templates": [ - "{{ if gt .Code 0 }}#f38ba8{{ end }}" - ], - "properties": { - "always_enabled": true - }, - "style": "plain", - "template": "{{ if gt .Code 0 }}{{ .Code }} {{ end }}# ", - "type": "status" - } - ], - "type": "prompt" - } - ], - "transient_prompt": { - "background": "transparent", - "foreground_templates": [ - "{{ if gt .Code 0 }}#f38ba8{{ end }}" - ], - "foreground": "#", - "template": "# " - }, - "version": 3 -} \ No newline at end of file diff --git a/quickshell/Modules/Bar/Components/CavaBar.qml b/quickshell/Modules/Bar/Components/CavaBar.qml index 59319ee..8bd9d06 100644 --- a/quickshell/Modules/Bar/Components/CavaBar.qml +++ b/quickshell/Modules/Bar/Components/CavaBar.qml @@ -55,8 +55,12 @@ Item { anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor - onClicked: { - MusicManager.playPause(); + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: (mouse) => { + if (mouse.button === Qt.LeftButton) + MusicManager.playPause(); + else if (mouse.button === Qt.RightButton) + SettingsService.showLyricsBar = !SettingsService.showLyricsBar; } onWheel: function(wheel) { if (wheel.angleDelta.y > 0) diff --git a/quickshell/apply-color b/quickshell/apply-color new file mode 100755 index 0000000..c60d661 --- /dev/null +++ b/quickshell/apply-color @@ -0,0 +1,16 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +if pgrep -x "quickshell" -u "$USER" >/dev/null; then + qs ipc call colors setPrimary ${colorHex} || { + log_error "Failed to send IPC command to quickshell" + exit 1 + } + + log_success "quickshell" +else + log_error "quickshell is not running. Cannot apply color." + exit 1 +fi \ No newline at end of file diff --git a/rofi/apply-color b/rofi/apply-color new file mode 100755 index 0000000..e43fe04 --- /dev/null +++ b/rofi/apply-color @@ -0,0 +1,18 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +file="$path"/config.rasi + +if pgrep -x "rofi" -u "$USER" > /dev/null; then + pkill -x rofi || log_error "Failed to kill rofi process" + # and move on +fi + +sed -i -E "s/^(\s*primary:\s*#)([0-9A-Fa-f]{6})(;)/\1${colorHex}\3/" "$file" || { + log_error "Failed to edit ${file}" + exit 1 +} + +log_success "rofi" \ No newline at end of file diff --git a/rofi/config.rasi.template b/rofi/config.rasi.template deleted file mode 100644 index 60d6ae8..0000000 --- a/rofi/config.rasi.template +++ /dev/null @@ -1,229 +0,0 @@ -/*****----- ALL -----*****/ -* { - font: "Maple Mono NF CN Semibold 10"; - base: #1e1e2e; - mantle: #181825; - text: #cdd6f4; - subtext0: #a6adc8; - surface2: #585b70; - surface: #292a3c; - red: #f38ba8; - green: #a6e3a1; - yellow: #f9e2af; - orange: #fab387; - blue: #89b4fa; - purple: #cba6f7; - cyan: #89dceb; - lavender: #b4befe; - sapphire: #74c7ec; - teal: #94e2d5; - peach: #fab387; - search: rgba(49, 50, 68, 0.5); // alpha(@surface, 0.5) - - primary: #; -} - - -/*****----- Configuration -----*****/ -configuration { - terminal: "/usr/bin/kitty"; - modi: "drun,run,ssh"; - show-icons: true; - display-drun: ""; - display-run: ""; - display-ssh: ""; - drun-display-format: "{name}"; - -} - -/*****----- Main Window -----*****/ -window { - /* properties for window widget */ - transparency: "real"; - location: center; - anchor: center; - fullscreen: false; - width: 600px; - x-offset: 0px; - y-offset: 0px; - - /* properties for all widgets */ - enabled: true; - margin: 0px; - padding: 0px; - border: 2px solid; - border-radius: 24px; - border-color: @primary; - cursor: "default"; - background-color: @base; -} - -/*****----- Main Box -----*****/ -mainbox { - enabled: true; - spacing: 0px; - margin: 0px; - padding: 30px; - background-color: transparent; - children: [ "inputbar", "message", "listview", "mode-switcher" ]; -} - -/*****----- Inputbar -----*****/ -inputbar { - enabled: true; - spacing: 0px; - padding: 75px 30px; - border-radius: 14px 14px 0 0; - background-color: transparent; - background-image: url("~/.config/backgrounds/nao-stars-crop-adjust-flop.jpg", width); - text-color: @text; - children: [ "textbox-prompt-colon", "entry" ]; -} - -prompt { - enabled: true; - background-color: inherit; - text-color: inherit; -} -textbox-prompt-colon { - enabled: true; - padding: 12px 15px; - expand: false; - str: " "; - background-color: @search; - border-radius: 14px; - text-color: inherit; -} -entry { - enabled: true; - padding: 12px 16px; - text-color: inherit; - cursor: text; - background-color: @search; - border-radius: 14px; - placeholder: "Search..."; - placeholder-color: inherit; -} - -/*****----- Listview -----*****/ -listview { - enabled: true; - columns: 2; - lines: 6; - cycle: true; - dynamic: true; - scrollbar: true; - layout: vertical; - reverse: false; - fixed-height: true; - fixed-columns: true; - - padding: 14px; - spacing: 5px; - background-color: @surface; - text-color: @text; - cursor: "default"; -} -scrollbar { - handle-width: 5px ; - handle-color: @primary; - border-radius: 10px; - background-color: @mantle; -} - -/*****----- Elements -----*****/ -element { - enabled: true; - spacing: 10px; - margin: 0px; - padding: 6px; - border-radius: 0px; - background-color: transparent; - text-color: @text; - cursor: pointer; -} -element normal.normal, -element alternate.normal { - background-color: transparent; - text-color: @text; -} -element normal.urgent, -element alternate.urgent, -element selected.active { - background-color: @primary; - text-color: @base; - border-radius: 10px; -} -element normal.active, -element alternate.active, -element selected.urgent { - background-color: @red; - text-color: @base; -} -element selected.normal { - background-color: @surface2; - text-color: @text; - border-radius: 10px; -} -element-icon { - background-color: transparent; - text-color: inherit; - size: 24px; - cursor: inherit; -} -element-text { - background-color: transparent; - text-color: inherit; - highlight: inherit; - cursor: inherit; - vertical-align: 0.5; - horizontal-align: 0.0; -} - -/*****----- Mode Switcher -----*****/ -mode-switcher{ - enabled: true; - spacing: 10px; - margin: 0px; - padding: 0px; - background-color: transparent; - text-color: @text; -} -button { - padding: 10px; - border-radius: 10px; - background-color: @base; - text-color: inherit; - cursor: pointer; -} -button selected { - background-color: @surface; - text-color: @primary; - border-radius: 0 0 14px 14px; - border-color: @primary; -} - -/*****----- Message -----*****/ -message { - enabled: true; - margin: 0px; - padding: 10px; - border-radius: 0px; - background-color: @mantle; - text-color: @text; -} -textbox { - background-color: transparent; - text-color: @text; - vertical-align: 0.5; - horizontal-align: 0.0; - highlight: none; - placeholder-color: @text; - blink: true; - markup: true; -} -error-message { - padding: 30px; - background-color: @base; - text-color: @text; -} \ No newline at end of file diff --git a/waybar/apply-color b/waybar/apply-color new file mode 100755 index 0000000..b010b3c --- /dev/null +++ b/waybar/apply-color @@ -0,0 +1,17 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +file="$path"/style.css + +sed -i -E "s/^(@define-color\s+flavor\s+#)([0-9A-Fa-f]{6})(;)/\1${colorHex}\3/" "$file" || { + log_error "Failed to edit ${file}" + exit 1 +} + +if pgrep -x "waybar" -u "$USER" > /dev/null; then + waybar-toggle restart || log_error "Failed to restart waybar" +fi + +log_success "waybar" \ No newline at end of file diff --git a/waybar/style.css.template b/waybar/style.css.template deleted file mode 100644 index e03b4f3..0000000 --- a/waybar/style.css.template +++ /dev/null @@ -1,217 +0,0 @@ -@import 'mocha.css'; - -@define-color flavor #; -/* @define-color archlinux #1793d1; */ -@define-color archlinux @sapphire; - -/* Font(s) */ -* { - /* main font icons CJK fallback */ - font-family: 'Sour Gummy Light', 'Meslo LGM Nerd Font Mono', 'WenQuanYi Micro Hei', 'Noto Sans', sans-serif; - font-size: 16px; -} - -/* Reset all styles */ -* { - border: none; - border-radius: 14px; - min-height: 0; - margin: 2px 1px 2px 1px; - padding: 0; - transition-property: background-color; - transition-duration: 0.5s; -} - -/* The whole bar */ -#waybar { - background: linear-gradient(to bottom, alpha(@base, 0.8), alpha(@base, 0)); - /* background: transparent; */ - color: @text; - border-radius: 0px; - margin: 0px; -} - -tooltip { - background: @base; - border: 2px solid @overlay0; -} - -#workspaceactions, -#window, -#clock, -#monitors, -#custom-mediaplayer, -#custom-power-menu, -#tray, -#custom-rofi, -#idle_inhibitor, -#custom-power { - padding: 0px 10px; -} - -#custom-separator { - padding: 0px 5px; - font-size: 20px; -} - -#custom-rofi, -#idle_inhibitor, -#custom-power, -#custom-expand-icon { - padding: 0px 6px; - font-size: 18px; -} - -#custom-workspacenew, -#workspaces button { - padding: 0px 5px; - margin: 3px 3px; - border-radius: 8px; - color: @flavor; - background-color: transparent; - transition: all 0.3s ease-in-out; -} - -#workspaces button:hover { - background-color: alpha(@flavor, 0.3); -} - -#workspaces button.active { - color: @base; - background: @flavor; -} - -#workspaces button.urgent { - color: @base; - background-color: @red; -} - -#workspaceactions { - padding-left: 1px; - padding-right: 1px; -} - -#workspaces { - padding: 0px; - margin: 0px; -} - -#window { - transition: none; /* Disable background transition */ -} - -window#waybar.empty #window { - background-color: transparent; - padding: 0; - margin: 0; -} - -#custom-mediaplayer { - color: @flavor; -} - -#network.speed { - color: @flavor; -} - -#custom-publicip { - color: @peach; -} - -#temperature { - color: @yellow; -} - -#memory { - color: @green; -} - -#cpu { - color: @teal; -} - -#battery { - color: @sapphire; -} - -#battery.charging, -#battery.full, -#battery.plugged { - color: @green; -} - -#backlight { - color: @blue; -} - -#wireplumber { - color: @lavender; -} - -#custom-power { - color: @maroon; -} - -#custom-power:hover { - background-color: alpha(@maroon, 0.3); -} - -#custom-rofi { - color: @archlinux; -} - -#custom-rofi:hover { - background-color: alpha(@archlinux, 0.3); -} - -#custom-expand-icon { - color: @green; -} - -#idle_inhibitor { - color: @yellow; -} - -#idle_inhibitor:hover { - background-color: alpha(@yellow, 0.3); -} - -#idle_inhibitor.activated { - color: @peach; -} - -#clock { - color: @flavor; -} - -@keyframes blink { - to { - background-color: alpha(@red, 0.5); - } -} - -#battery.critical:not(.charging) { - color: @red; - animation-name: blink; - animation-duration: 1s; - animation-timing-function: linear; - animation-iteration-count: infinite; - animation-direction: alternate; -} - -#network.disconnected { - color: @red; -} - -#temperature.critical { - background-color: #eb4d4b; -} - -#tray > .passive { - -gtk-icon-effect: dim; -} - -#tray > .needs-attention { - -gtk-icon-effect: highlight; - background-color: #eb4d4b; -} diff --git a/waybar/waybar.sh b/waybar/waybar.sh index d03b9eb..ddd5a2e 100755 --- a/waybar/waybar.sh +++ b/waybar/waybar.sh @@ -4,7 +4,7 @@ killall -q waybar # Wait until the processes have been shut down -while pgrep -x waybar >/dev/null; do sleep 1; done +while pgrep -x waybar -u "$USER" >/dev/null; do sleep 1; done # Launch main waybar & diff --git a/wlogout-niri/apply-color b/wlogout-niri/apply-color new file mode 100755 index 0000000..113ca6d --- /dev/null +++ b/wlogout-niri/apply-color @@ -0,0 +1,22 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + + +for file in "$path"/icons/*.svg; do + [ -f "$file" ] || continue + sed -i -E "s/(fill=\"#)([0-9A-Fa-f]{6})(\")/\1${colorHex}\3/" "$file" || { + log_error "Failed to edit ${file}" + exit 1 + } +done + +file="$path"/style.css + +sed -i -E "s/(border-color:\s*#)([0-9A-Fa-f]{6})(;)/\1${colorHex}\3/" "$file" || { + log_error "Failed to edit ${file}" + exit 1 +} + +log_success "wlogout (niri version)" \ No newline at end of file diff --git a/wlogout-niri/icons/hibernate.svg.template b/wlogout-niri/icons/hibernate.svg.template deleted file mode 100644 index 22b5945..0000000 --- a/wlogout-niri/icons/hibernate.svg.template +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - - diff --git a/wlogout-niri/icons/lock.svg.template b/wlogout-niri/icons/lock.svg.template deleted file mode 100644 index 83628cb..0000000 --- a/wlogout-niri/icons/lock.svg.template +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - - diff --git a/wlogout-niri/icons/logout.svg.template b/wlogout-niri/icons/logout.svg.template deleted file mode 100644 index 669ecd8..0000000 --- a/wlogout-niri/icons/logout.svg.template +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - - diff --git a/wlogout-niri/icons/reboot.svg.template b/wlogout-niri/icons/reboot.svg.template deleted file mode 100644 index 8ee393a..0000000 --- a/wlogout-niri/icons/reboot.svg.template +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - - diff --git a/wlogout-niri/icons/shutdown.svg.template b/wlogout-niri/icons/shutdown.svg.template deleted file mode 100644 index 0dc8f51..0000000 --- a/wlogout-niri/icons/shutdown.svg.template +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - - diff --git a/wlogout-niri/icons/suspend.svg.template b/wlogout-niri/icons/suspend.svg.template deleted file mode 100644 index 1c96603..0000000 --- a/wlogout-niri/icons/suspend.svg.template +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - - diff --git a/wlogout-niri/style.css.template b/wlogout-niri/style.css.template deleted file mode 100644 index dc766d9..0000000 --- a/wlogout-niri/style.css.template +++ /dev/null @@ -1,120 +0,0 @@ -* { - background-image: none; - font-size: 24px; - font-family: 'Sour Gummy Light'; -} - -window { - background-color: rgba(30, 30, 46, 0.5); -} - -button { - color: #cdd6f4; - border-radius: 0; - outline-style: none; - background-color: alpha(#1e1e2e, 1); - border: none; - border-width: 0px; - border-radius: 0px; - border-color: #; - box-shadow: none; - text-shadow: none; - text-decoration-color: #cdd6f4; - background-repeat: no-repeat; - background-position: center; - background-size: 20%; - animation: gradient_f 20s ease-in infinite; -} - -button:focus, -button:active, -button:hover { - background-size: 20%; - background-color: alpha(#1c1c2c, 1); - animation: gradient_f 20s ease-in infinite; - transition: all 0.3s cubic-bezier(0.55, 0, 0.28, 1.682); -} - -#lock { - background-image: image(url('./icons/lock.svg')); - border-radius: 32px 0 0 0; -} - -#logout { - background-image: image(url('./icons/logout.svg')); -} - -#suspend { - background-image: image(url('./icons/suspend.svg')); - border-radius: 0 32px 0 0; -} - -#hibernate { - background-image: image(url('./icons/hibernate.svg')); - border-radius: 0 0 0 32px; -} - -#shutdown { - background-image: image(url('./icons/shutdown.svg')); -} - -#reboot { - background-image: image(url('./icons/reboot.svg')); - border-radius: 0 0 32px 0; -} - -#lock:hover { - border-radius: 30px 0 0 0; - margin: -30px 0 0 -30px; -} - -#logout:hover { - margin: -30px 0 0 0; -} - -#suspend:hover { - border-radius: 0 30px 0 0; - margin: -30px -30px 0 0; -} - -#hibernate:hover { - border-radius: 0 0 0 30px; - margin: 0 0 -30 -30px; -} - -#shutdown:hover { - margin: 0 0 -30px 0; -} - -#reboot:hover { - border-radius: 0 0 30px 0; - margin: 0 -30px -30px 0; -} - -#lock:focus { - border-radius: 60px 0 0 0; - margin: -60px 0 0 -60px; -} - -#logout:focus { - margin: -60px 0 0 0; -} - -#suspend:focus { - border-radius: 0 60px 0 0; - margin: -60px -60px 0 0; -} - -#hibernate:focus { - border-radius: 0 0 0 60px; - margin: 0 0 -60 -60px; -} - -#shutdown:focus { - margin: 0 0 -60px 0; -} - -#reboot:focus { - border-radius: 0 0 60px 0; - margin: 0 -60px -60px 0; -} diff --git a/wlogout/apply-color b/wlogout/apply-color new file mode 100755 index 0000000..c7220f4 --- /dev/null +++ b/wlogout/apply-color @@ -0,0 +1,23 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +file="$path"/style.css + +for file in "$path"/icons/*.svg; do + [ -f "$file" ] || continue + sed -i -E "s/(fill=\"#)([0-9A-Fa-f]{6})(\")/\1${colorHex}\3/" "$file" || { + log_error "Failed to edit ${file}" + exit 1 + } +done + +file="$path"/style.css + +sed -i -E "s/(border-color:\s*#)([0-9A-Fa-f]{6})(;)/\1${colorHex}\3/" "$file" || { + log_error "Failed to edit ${file}" + exit 1 +} + +log_success "wlogout" \ No newline at end of file diff --git a/wlogout/icons/hibernate.svg.template b/wlogout/icons/hibernate.svg.template deleted file mode 100644 index 22b5945..0000000 --- a/wlogout/icons/hibernate.svg.template +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - - diff --git a/wlogout/icons/lock.svg.template b/wlogout/icons/lock.svg.template deleted file mode 100644 index 83628cb..0000000 --- a/wlogout/icons/lock.svg.template +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - - diff --git a/wlogout/icons/logout.svg.template b/wlogout/icons/logout.svg.template deleted file mode 100644 index 669ecd8..0000000 --- a/wlogout/icons/logout.svg.template +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - - diff --git a/wlogout/icons/reboot.svg.template b/wlogout/icons/reboot.svg.template deleted file mode 100644 index 8ee393a..0000000 --- a/wlogout/icons/reboot.svg.template +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - - diff --git a/wlogout/icons/shutdown.svg.template b/wlogout/icons/shutdown.svg.template deleted file mode 100644 index 0dc8f51..0000000 --- a/wlogout/icons/shutdown.svg.template +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - - diff --git a/wlogout/icons/suspend.svg.template b/wlogout/icons/suspend.svg.template deleted file mode 100644 index 1c96603..0000000 --- a/wlogout/icons/suspend.svg.template +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Svg Vector Icons : http://www.onlinewebfonts.com/icon - - diff --git a/wlogout/style.css.template b/wlogout/style.css.template deleted file mode 100644 index 1384e56..0000000 --- a/wlogout/style.css.template +++ /dev/null @@ -1,120 +0,0 @@ -* { - background-image: none; - font-size: 24px; - font-family: 'Sour Gummy Light'; -} - -window { - background-color: rgba(30, 30, 46, 0.5); -} - -button { - color: #cdd6f4; - border-radius: 0; - outline-style: none; - background-color: alpha(#1e1e2e, 0.8); - border: none; - border-width: 0px; - border-radius: 0px; - border-color: #; - box-shadow: none; - text-shadow: none; - text-decoration-color: #cdd6f4; - background-repeat: no-repeat; - background-position: center; - background-size: 20%; - animation: gradient_f 20s ease-in infinite; -} - -button:focus, -button:active, -button:hover { - background-size: 20%; - background-color: alpha(#1e1e2e, 0.7); - animation: gradient_f 20s ease-in infinite; - transition: all 0.3s cubic-bezier(0.55, 0, 0.28, 1.682); -} - -#lock { - background-image: image(url('./icons/lock.svg')); - border-radius: 32px 0 0 0; -} - -#logout { - background-image: image(url('./icons/logout.svg')); -} - -#suspend { - background-image: image(url('./icons/suspend.svg')); - border-radius: 0 32px 0 0; -} - -#hibernate { - background-image: image(url('./icons/hibernate.svg')); - border-radius: 0 0 0 32px; -} - -#shutdown { - background-image: image(url('./icons/shutdown.svg')); -} - -#reboot { - background-image: image(url('./icons/reboot.svg')); - border-radius: 0 0 32px 0; -} - -#lock:hover { - border-radius: 30px 0 0 0; - margin: -30px 0 0 -30px; -} - -#logout:hover { - margin: -30px 0 0 0; -} - -#suspend:hover { - border-radius: 0 30px 0 0; - margin: -30px -30px 0 0; -} - -#hibernate:hover { - border-radius: 0 0 0 30px; - margin: 0 0 -30 -30px; -} - -#shutdown:hover { - margin: 0 0 -30px 0; -} - -#reboot:hover { - border-radius: 0 0 30px 0; - margin: 0 -30px -30px 0; -} - -#lock:focus { - border-radius: 60px 0 0 0; - margin: -60px 0 0 -60px; -} - -#logout:focus { - margin: -60px 0 0 0; -} - -#suspend:focus { - border-radius: 0 60px 0 0; - margin: -60px -60px 0 0; -} - -#hibernate:focus { - border-radius: 0 0 0 60px; - margin: 0 0 -60 -60px; -} - -#shutdown:focus { - margin: 0 0 -60px 0; -} - -#reboot:focus { - border-radius: 0 0 60px 0; - margin: 0 -60px -60px 0; -} diff --git a/yazi/apply-color b/yazi/apply-color new file mode 100755 index 0000000..55af46e --- /dev/null +++ b/yazi/apply-color @@ -0,0 +1,11 @@ +#!/bin/sh + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +cp -f "$path"/../.yazi-themes/catppuccin-mocha-"$colorName".toml "$path"/../yazi/theme.toml || { + log_error "Failed to copy theme file" + exit 1 +} + +log_success "yazi" \ No newline at end of file