🔧 chore(config, settings, utils): update file paths for consistency and correctness

This commit is contained in:
sankalp committed 2025-06-22 20:15:07 +05:45
1 parent 25b3cebcc2
commit 78ea888eac
6 files changed
+65 -60

No files matched your search

+9 -8
View File
@@ -1,7 +1,10 @@
import os
import shutil
import sys
from pathlib import Path
from fabric import Application
def _configure_sys_path_for_direct_execution():
"""
@@ -16,13 +19,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 +41,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 +54,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 +70,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 -3
View File
@@ -1,9 +1,9 @@
from gi.repository import Gdk, GLib
from fabric.utils.helpers import get_relative_path
import json
import os
import gi
from fabric.utils.helpers import get_relative_path
from gi.repository import Gdk, GLib
gi.require_version("Gtk", "3.0")
@@ -20,7 +20,7 @@ USERNAME = os.getlogin()
HOSTNAME = os.uname().nodename
HOME_DIR = os.path.expanduser("~")
CONFIG_DIR = os.path.expanduser(f"~/{APP_NAME}")
CONFIG_DIR = os.path.expanduser(f"~/.config/{APP_NAME}")
screen = Gdk.Screen.get_default()
CURRENT_WIDTH = screen.get_width()
+1 -4
View File
@@ -1,14 +1,11 @@
from config.data import (
APP_NAME,
APP_NAME_CAP,
NOTIF_POS_DEFAULT,
NOTIF_POS_KEY,
WALLPAPERS_DIR_DEFAULT,
)
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 = {
+21 -19
View File
@@ -1,25 +1,23 @@
from config.settings.utils import backup_and_replace, bind_vars, start_config
from config.data import APP_NAME, APP_NAME_CAP, NOTIF_POS_DEFAULT, NOTIF_POS_KEY
from PIL import Image
from gi.repository import GdkPixbuf, GLib, Gtk
from fabric.widgets.window import Window
from fabric.widgets.stack import Stack
from fabric.widgets.scrolledwindow import ScrolledWindow
from fabric.widgets.scale import Scale
from fabric.widgets.label import Label
from fabric.widgets.image import Image as FabricImage
from fabric.widgets.entry import Entry
from fabric.widgets.button import Button
from fabric.widgets.box import Box
import json
import os
import shutil
import subprocess
import threading
import time
from pathlib import Path
import gi
from fabric.widgets.box import Box
from fabric.widgets.button import Button
from fabric.widgets.entry import Entry
from fabric.widgets.image import Image as FabricImage
from fabric.widgets.label import Label
from fabric.widgets.scrolledwindow import ScrolledWindow
from fabric.widgets.stack import Stack
from fabric.widgets.window import Window
from gi.repository import GdkPixbuf, GLib, Gtk
from PIL import Image
from config.data import APP_NAME, APP_NAME_CAP, NOTIF_POS_DEFAULT, NOTIF_POS_KEY
from config.settings.utils import backup_and_replace, bind_vars, start_config
gi.require_version("Gtk", "3.0")
@@ -907,7 +905,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 +933,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 +945,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 +985,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:
+28 -23
View File
@@ -1,19 +1,18 @@
from config.data import ( # CONFIG_DIR, HOME_DIR no se usan aquí directamente
APP_NAME,
APP_NAME_CAP,
)
from config.settings import constants as settings_constants
from gi.repository import GLib
from fabric.utils.helpers import exec_shell_command_async
import json
import os
import shutil
import subprocess
import time
from pathlib import Path
import gi
import toml
from fabric.utils.helpers import exec_shell_command_async
from config.data import ( # CONFIG_DIR, HOME_DIR no se usan aquí directamente
APP_NAME,
APP_NAME_CAP,
)
from config.settings import constants as settings_constants
gi.require_version("Gtk", "3.0")
@@ -76,12 +75,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 +123,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 +139,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 +193,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 +249,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,13 +282,13 @@ 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
# Wallpapers directory: {bind_vars.get("wallpapers_dir", "~/Modus/assets/wallpapers_example")}
source = {home}/{APP_NAME_CAP}/config/hypr/colors.conf
source = {home}/.config/{APP_NAME_CAP}/config/hypr/colors.conf
layerrule = noanim, fabric
@@ -338,7 +341,9 @@ def ensure_face_icon():
Ensure the face icon exists. If not, copy the default icon.
"""
face_icon_path = os.path.expanduser("~/.face.icon")
default_icon_path = os.path.expanduser(f"~/{APP_NAME_CAP}/assets/default.png")
default_icon_path = os.path.expanduser(
f"~/.config/{APP_NAME_CAP}/assets/default.png"
)
if not os.path.exists(face_icon_path) and os.path.exists(default_icon_path):
try:
shutil.copy(default_icon_path, face_icon_path)
@@ -375,7 +380,7 @@ def start_config():
ensure_face_icon()
print(f"{time.time():.4f}: start_config: Generating hypr conf...")
hypr_config_dir = os.path.expanduser(f"~/{APP_NAME_CAP}/config/hypr/")
hypr_config_dir = os.path.expanduser(f"~/.config/{APP_NAME_CAP}/config/hypr/")
os.makedirs(hypr_config_dir, exist_ok=True)
# Usar APP_NAME para el nombre del archivo .conf para que coincida con SOURCE_STRING corregido
hypr_conf_path = os.path.join(hypr_config_dir, f"{APP_NAME}.conf")
+3 -3
View File
@@ -9,10 +9,10 @@ from loguru import logger
from config.data import APP_NAME, APP_NAME_CAP, CONFIG_FILE
from modules.corners import Corners
from modules.dock.main import Dock
from modules.switcher import ApplicationSwitcher
from modules.osd import OSD
from modules.launcher import Launcher
from modules.notification_popup import NotificationPopup
from modules.osd import OSD
from modules.switcher import ApplicationSwitcher
gi.require_version("GLib", "2.0")
@@ -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)