🔧 config, data, settings: use user-specific config paths instead of hardcoded paths

This commit is contained in:
sankalp committed 2025-06-22 20:05:10 +05:45
1 parent c323b4ead9
commit 380e2dbb1a
7 files changed
+39 -27

No files matched your search

+2
View File
@@ -2,3 +2,5 @@
<img src="assets/modus.png" alt="Modus Logo" width="128" height="128">
**A modular and extensible shell for Hyprland, powered by Fabric**
</div>
+8 -8
View File
@@ -1,3 +1,5 @@
from fabric import Application
import shutil
import os
import sys
from pathlib import Path
@@ -16,13 +18,11 @@ def _configure_sys_path_for_direct_execution():
if str(project_root) not in sys.path:
sys.path.insert(0, str(project_root))
_configure_sys_path_for_direct_execution()
import shutil
from fabric import Application
if __name__ == "__main__" and (__package__ is None or __package__ == ''):
if __name__ == "__main__" and (__package__ is None or __package__ == ""):
from config.data import APP_NAME, APP_NAME_CAP
from config.settings.gui import HyprConfGUI
from config.settings.utils import load_bind_vars
@@ -40,12 +40,12 @@ def open_config():
show_lock_checkbox = True
dest_lock = os.path.expanduser("~/.config/hypr/hyprlock.conf")
src_lock = os.path.expanduser(f"~/{APP_NAME_CAP}/config/hypr/hyprlock.conf")
src_lock = os.path.expanduser(f"~/.config/{APP_NAME_CAP}/config/hypr/hyprlock.conf")
if not os.path.exists(dest_lock) and os.path.exists(src_lock):
try:
os.makedirs(os.path.dirname(dest_lock), exist_ok=True)
shutil.copy(src_lock, dest_lock)
show_lock_checkbox = False
show_lock_checkbox = False
print(f"Copied default hyprlock config to {dest_lock}")
except Exception as e:
print(f"Error copying default hyprlock config: {e}")
@@ -53,7 +53,7 @@ def open_config():
show_idle_checkbox = True
dest_idle = os.path.expanduser("~/.config/hypr/hypridle.conf")
src_idle = os.path.expanduser(f"~/{APP_NAME_CAP}/config/hypr/hypridle.conf")
src_idle = os.path.expanduser(f"~/.config/{APP_NAME_CAP}/config/hypr/hypridle.conf")
if not os.path.exists(dest_idle) and os.path.exists(src_idle):
try:
os.makedirs(os.path.dirname(dest_idle), exist_ok=True)
@@ -69,7 +69,7 @@ def open_config():
show_lock_checkbox=show_lock_checkbox,
show_idle_checkbox=show_idle_checkbox,
application=app,
on_destroy=lambda *_: app.quit()
on_destroy=lambda *_: app.quit(),
)
app.add_window(window)
+3 -1
View File
@@ -40,7 +40,9 @@ DOCK_THEME = "Pills"
def load_config():
"""Load the configuration from config.json"""
config_path = os.path.expanduser(f"~/{APP_NAME_CAP}/config/json/config.json")
config_path = os.path.expanduser(
f"~/.config/{APP_NAME_CAP}/config/json/config.json"
)
config = {}
if os.path.exists(config_path):
+1 -1
View File
@@ -8,7 +8,7 @@ from config.data import (
SOURCE_STRING = f"""
# {APP_NAME_CAP}
source = ~/{APP_NAME_CAP}/config/hypr/{APP_NAME}.conf
source = ~/.config/{APP_NAME_CAP}/config/hypr/{APP_NAME}.conf
"""
DEFAULTS = {
+8 -4
View File
@@ -907,7 +907,7 @@ class HyprConfGUI(Window):
print(f"{start_time:.4f}: Background task started.")
config_json = os.path.expanduser(
f"~/{APP_NAME_CAP}/config/json/config.json"
f"~/.config/{APP_NAME_CAP}/config/json/config.json"
)
os.makedirs(os.path.dirname(config_json), exist_ok=True)
try:
@@ -935,7 +935,9 @@ class HyprConfGUI(Window):
if replace_lock:
print(f"{time.time():.4f}: Replacing hyprlock config...")
src = os.path.expanduser(f"~/{APP_NAME_CAP}/config/hypr/hyprlock.conf")
src = os.path.expanduser(
f"~/.config/{APP_NAME_CAP}/config/hypr/hyprlock.conf"
)
dest = os.path.expanduser("~/.config/hypr/hyprlock.conf")
if os.path.exists(src):
backup_and_replace(src, dest, "Hyprlock")
@@ -945,7 +947,9 @@ class HyprConfGUI(Window):
if replace_idle:
print(f"{time.time():.4f}: Replacing hypridle config...")
src = os.path.expanduser(f"~/{APP_NAME_CAP}/config/hypr/hypridle.conf")
src = os.path.expanduser(
f"~/.config/{APP_NAME_CAP}/config/hypr/hypridle.conf"
)
dest = os.path.expanduser("~/.config/hypr/hypridle.conf")
if os.path.exists(src):
backup_and_replace(src, dest, "Hypridle")
@@ -983,7 +987,7 @@ class HyprConfGUI(Window):
print(f"{time.time():.4f}: Finished start_config().")
print(f"{time.time():.4f}: Initiating Modus restart using Popen...")
main_py = os.path.expanduser(f"~/{APP_NAME_CAP}/main.py")
main_py = os.path.expanduser(f"~/.config/{APP_NAME_CAP}/main.py")
kill_cmd = f"killall {APP_NAME}"
start_cmd = ["uwsm", "app", "--", "python", main_py]
try:
+16 -12
View File
@@ -76,12 +76,12 @@ def ensure_matugen_config():
},
"templates": {
"hyprland": {
"input_path": f"~/{APP_NAME_CAP}/config/matugen/templates/hyprland-colors.conf",
"output_path": f"~/{APP_NAME_CAP}/config/hypr/colors.conf",
"input_path": f"~/.config/{APP_NAME_CAP}/config/matugen/templates/hyprland-colors.conf",
"output_path": f"~/.config/{APP_NAME_CAP}/config/hypr/colors.conf",
},
f"{APP_NAME}": {
"input_path": f"~/{APP_NAME_CAP}/config/matugen/templates/{APP_NAME}.css",
"output_path": f"~/{APP_NAME_CAP}/styles/colors.css",
"input_path": f"~/.config/{APP_NAME_CAP}/config/matugen/templates/{APP_NAME}.css",
"output_path": f"~/.config/{APP_NAME_CAP}/styles/colors.css",
"post_hook": f"fabric-cli exec {APP_NAME} 'app.set_css()' &",
},
},
@@ -124,8 +124,10 @@ def ensure_matugen_config():
print(f"Error writing matugen config to {config_path}: {e}")
current_wall = os.path.expanduser("~/.current.wall")
hypr_colors = os.path.expanduser(f"~/{APP_NAME_CAP}/config/hypr/colors.conf")
css_colors = os.path.expanduser(f"~/{APP_NAME_CAP}/styles/colors.css")
hypr_colors = os.path.expanduser(
f"~/.config/{APP_NAME_CAP}/config/hypr/colors.conf"
)
css_colors = os.path.expanduser(f"~/.config/{APP_NAME_CAP}/styles/colors.css")
if (
not os.path.exists(current_wall)
@@ -138,7 +140,7 @@ def ensure_matugen_config():
image_path = ""
if not os.path.exists(current_wall):
example_wallpaper_path = os.path.expanduser(
f"~/{APP_NAME_CAP}/assets/wallpapers_example/example-1.jpg"
f"~/.config/{APP_NAME_CAP}/assets/wallpapers_example/example-1.jpg"
)
if os.path.exists(example_wallpaper_path):
try:
@@ -192,7 +194,9 @@ def load_bind_vars():
# Usar .copy() para no modificar DEFAULTS accidentalmente
bind_vars.update(settings_constants.DEFAULTS.copy())
config_json = os.path.expanduser(f"~/{APP_NAME_CAP}/config/json/config.json")
config_json = os.path.expanduser(
f"~/.config/{APP_NAME_CAP}/config/json/config.json"
)
if os.path.exists(config_json):
try:
with open(config_json, "r") as f:
@@ -246,17 +250,17 @@ def generate_hyprconf() -> str:
is_vertical = bar_position in ["Left", "Right"]
animation_type = "slidefadevert" if is_vertical else "slidefade"
return f"""exec-once = uwsm-app $(python {home}/{APP_NAME_CAP}/main.py)
return f"""exec-once = uwsm-app $(python {home}/.config/{APP_NAME_CAP}/main.py)
exec = pgrep -x "hypridle" > /dev/null || uwsm app -- hypridle
exec = uwsm app -- swww-daemon
exec-once = wl-paste --type text --watch cliphist store
exec-once = wl-paste --type image --watch cliphist store
$fabricSend = fabric-cli exec {APP_NAME}
$axMessage = notify-send "Modus" "FIRE IN THE HOLE‼️🗣️🔥🕳️" -i "{home}/{APP_NAME_CAP}/assets/modus.png" -A "🗣️" -A "🔥" -A "🕳️" -a "Source Code"
$axMessage = notify-send "Modus" "FIRE IN THE HOLE‼️🗣️🔥🕳️" -i "{home}/{AP.config / P_NAME_CAP}/assets/modus.png" -A "🗣️" -A "🔥" -A "🕳️" -a "Source Code"
# Reload {APP_NAME_CAP}
bind = {bind_vars.get("prefix_restart", "ALT SHIFT")}, {bind_vars.get("suffix_restart", "R")}, exec, killall {APP_NAME}; uwsm-app $(python {home}/{APP_NAME_CAP}/main.py)
bind = {bind_vars.get("prefix_restart", "ALT SHIFT")}, {bind_vars.get("suffix_restart", "R")}, exec, killall {APP_NAME}; uwsm-app $(python {home}/.config/{APP_NAME_CAP}/main.py)
# Message
bind = {bind_vars.get("prefix_msg", "SUPER")}, {bind_vars.get("suffix_msg", "A")}, exec, $Message
# Application Switcher
@@ -279,7 +283,7 @@ bind = {bind_vars.get("prefix_power", "SUPER")}, {bind_vars.get("suffix_power",
# Toggle Caffeine
bind = {bind_vars.get("prefix_caffeine", "SUPER SHIFT")}, {bind_vars.get("suffix_caffeine", "M")}, exec, $fabricSend "launcher.show_launcher('caffeine on', external=True)"
# Settings
bind = {bind_vars.get("prefix_settings", "SUPER")}, {bind_vars.get("suffix_settings", "I")}, exec, uwsm-app $(python {home}/{APP_NAME_CAP}/config/config.py) # Settings
bind = {bind_vars.get("prefix_settings", "SUPER")}, {bind_vars.get("suffix_settings", "I")}, exec, uwsm-app $(python {home}/.config/{APP_NAME_CAP}/config/config.py) # Settings
# Restart Modus
bind = {bind_vars.get("prefix_restart_inspector", "SUPER CTRL ALT")}, {bind_vars.get("suffix_restart_inspector", "B")}, exec, killall {APP_NAME}; uwsm-app $(GTK_DEBUG=interactive python {home}/.config/{APP_NAME_CAP}/main.py) # Restart with inspector
+1 -1
View File
@@ -35,7 +35,7 @@ if __name__ == "__main__":
current_wallpaper = os.path.expanduser("~/.current.wall")
if not os.path.exists(current_wallpaper):
example_wallpaper = os.path.expanduser(
f"~/{APP_NAME_CAP}/assets/wallpapers_example/example-1.png"
f"~/.config/{APP_NAME_CAP}/assets/wallpapers_example/example-1.png"
)
os.symlink(example_wallpaper, current_wallpaper)