🔧 config, data, settings: use user-specific config paths instead of hardcoded paths
This commit is contained in:
7 files changed
+39
-27
No files matched your search
@@ -2,3 +2,5 @@
|
|||||||
<img src="assets/modus.png" alt="Modus Logo" width="128" height="128">
|
<img src="assets/modus.png" alt="Modus Logo" width="128" height="128">
|
||||||
|
|
||||||
**A modular and extensible shell for Hyprland, powered by Fabric**
|
**A modular and extensible shell for Hyprland, powered by Fabric**
|
||||||
|
|
||||||
|
</div>
|
||||||
+8
-8
@@ -1,3 +1,5 @@
|
|||||||
|
from fabric import Application
|
||||||
|
import shutil
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -16,13 +18,11 @@ def _configure_sys_path_for_direct_execution():
|
|||||||
if str(project_root) not in sys.path:
|
if str(project_root) not in sys.path:
|
||||||
sys.path.insert(0, str(project_root))
|
sys.path.insert(0, str(project_root))
|
||||||
|
|
||||||
|
|
||||||
_configure_sys_path_for_direct_execution()
|
_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.data import APP_NAME, APP_NAME_CAP
|
||||||
from config.settings.gui import HyprConfGUI
|
from config.settings.gui import HyprConfGUI
|
||||||
from config.settings.utils import load_bind_vars
|
from config.settings.utils import load_bind_vars
|
||||||
@@ -40,12 +40,12 @@ def open_config():
|
|||||||
|
|
||||||
show_lock_checkbox = True
|
show_lock_checkbox = True
|
||||||
dest_lock = os.path.expanduser("~/.config/hypr/hyprlock.conf")
|
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):
|
if not os.path.exists(dest_lock) and os.path.exists(src_lock):
|
||||||
try:
|
try:
|
||||||
os.makedirs(os.path.dirname(dest_lock), exist_ok=True)
|
os.makedirs(os.path.dirname(dest_lock), exist_ok=True)
|
||||||
shutil.copy(src_lock, dest_lock)
|
shutil.copy(src_lock, dest_lock)
|
||||||
show_lock_checkbox = False
|
show_lock_checkbox = False
|
||||||
print(f"Copied default hyprlock config to {dest_lock}")
|
print(f"Copied default hyprlock config to {dest_lock}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error copying default hyprlock config: {e}")
|
print(f"Error copying default hyprlock config: {e}")
|
||||||
@@ -53,7 +53,7 @@ def open_config():
|
|||||||
|
|
||||||
show_idle_checkbox = True
|
show_idle_checkbox = True
|
||||||
dest_idle = os.path.expanduser("~/.config/hypr/hypridle.conf")
|
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):
|
if not os.path.exists(dest_idle) and os.path.exists(src_idle):
|
||||||
try:
|
try:
|
||||||
os.makedirs(os.path.dirname(dest_idle), exist_ok=True)
|
os.makedirs(os.path.dirname(dest_idle), exist_ok=True)
|
||||||
@@ -69,7 +69,7 @@ def open_config():
|
|||||||
show_lock_checkbox=show_lock_checkbox,
|
show_lock_checkbox=show_lock_checkbox,
|
||||||
show_idle_checkbox=show_idle_checkbox,
|
show_idle_checkbox=show_idle_checkbox,
|
||||||
application=app,
|
application=app,
|
||||||
on_destroy=lambda *_: app.quit()
|
on_destroy=lambda *_: app.quit(),
|
||||||
)
|
)
|
||||||
app.add_window(window)
|
app.add_window(window)
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -40,7 +40,9 @@ DOCK_THEME = "Pills"
|
|||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
"""Load the configuration from config.json"""
|
"""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 = {}
|
config = {}
|
||||||
|
|
||||||
if os.path.exists(config_path):
|
if os.path.exists(config_path):
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from config.data import (
|
|||||||
|
|
||||||
SOURCE_STRING = f"""
|
SOURCE_STRING = f"""
|
||||||
# {APP_NAME_CAP}
|
# {APP_NAME_CAP}
|
||||||
source = ~/{APP_NAME_CAP}/config/hypr/{APP_NAME}.conf
|
source = ~/.config/{APP_NAME_CAP}/config/hypr/{APP_NAME}.conf
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
|
|||||||
@@ -907,7 +907,7 @@ class HyprConfGUI(Window):
|
|||||||
print(f"{start_time:.4f}: Background task started.")
|
print(f"{start_time:.4f}: Background task started.")
|
||||||
|
|
||||||
config_json = os.path.expanduser(
|
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)
|
os.makedirs(os.path.dirname(config_json), exist_ok=True)
|
||||||
try:
|
try:
|
||||||
@@ -935,7 +935,9 @@ class HyprConfGUI(Window):
|
|||||||
|
|
||||||
if replace_lock:
|
if replace_lock:
|
||||||
print(f"{time.time():.4f}: Replacing hyprlock config...")
|
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")
|
dest = os.path.expanduser("~/.config/hypr/hyprlock.conf")
|
||||||
if os.path.exists(src):
|
if os.path.exists(src):
|
||||||
backup_and_replace(src, dest, "Hyprlock")
|
backup_and_replace(src, dest, "Hyprlock")
|
||||||
@@ -945,7 +947,9 @@ class HyprConfGUI(Window):
|
|||||||
|
|
||||||
if replace_idle:
|
if replace_idle:
|
||||||
print(f"{time.time():.4f}: Replacing hypridle config...")
|
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")
|
dest = os.path.expanduser("~/.config/hypr/hypridle.conf")
|
||||||
if os.path.exists(src):
|
if os.path.exists(src):
|
||||||
backup_and_replace(src, dest, "Hypridle")
|
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}: Finished start_config().")
|
||||||
|
|
||||||
print(f"{time.time():.4f}: Initiating Modus restart using Popen...")
|
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}"
|
kill_cmd = f"killall {APP_NAME}"
|
||||||
start_cmd = ["uwsm", "app", "--", "python", main_py]
|
start_cmd = ["uwsm", "app", "--", "python", main_py]
|
||||||
try:
|
try:
|
||||||
|
|||||||
+16
-12
@@ -76,12 +76,12 @@ def ensure_matugen_config():
|
|||||||
},
|
},
|
||||||
"templates": {
|
"templates": {
|
||||||
"hyprland": {
|
"hyprland": {
|
||||||
"input_path": f"~/{APP_NAME_CAP}/config/matugen/templates/hyprland-colors.conf",
|
"input_path": f"~/.config/{APP_NAME_CAP}/config/matugen/templates/hyprland-colors.conf",
|
||||||
"output_path": f"~/{APP_NAME_CAP}/config/hypr/colors.conf",
|
"output_path": f"~/.config/{APP_NAME_CAP}/config/hypr/colors.conf",
|
||||||
},
|
},
|
||||||
f"{APP_NAME}": {
|
f"{APP_NAME}": {
|
||||||
"input_path": f"~/{APP_NAME_CAP}/config/matugen/templates/{APP_NAME}.css",
|
"input_path": f"~/.config/{APP_NAME_CAP}/config/matugen/templates/{APP_NAME}.css",
|
||||||
"output_path": f"~/{APP_NAME_CAP}/styles/colors.css",
|
"output_path": f"~/.config/{APP_NAME_CAP}/styles/colors.css",
|
||||||
"post_hook": f"fabric-cli exec {APP_NAME} 'app.set_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}")
|
print(f"Error writing matugen config to {config_path}: {e}")
|
||||||
|
|
||||||
current_wall = os.path.expanduser("~/.current.wall")
|
current_wall = os.path.expanduser("~/.current.wall")
|
||||||
hypr_colors = os.path.expanduser(f"~/{APP_NAME_CAP}/config/hypr/colors.conf")
|
hypr_colors = os.path.expanduser(
|
||||||
css_colors = os.path.expanduser(f"~/{APP_NAME_CAP}/styles/colors.css")
|
f"~/.config/{APP_NAME_CAP}/config/hypr/colors.conf"
|
||||||
|
)
|
||||||
|
css_colors = os.path.expanduser(f"~/.config/{APP_NAME_CAP}/styles/colors.css")
|
||||||
|
|
||||||
if (
|
if (
|
||||||
not os.path.exists(current_wall)
|
not os.path.exists(current_wall)
|
||||||
@@ -138,7 +140,7 @@ def ensure_matugen_config():
|
|||||||
image_path = ""
|
image_path = ""
|
||||||
if not os.path.exists(current_wall):
|
if not os.path.exists(current_wall):
|
||||||
example_wallpaper_path = os.path.expanduser(
|
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):
|
if os.path.exists(example_wallpaper_path):
|
||||||
try:
|
try:
|
||||||
@@ -192,7 +194,9 @@ def load_bind_vars():
|
|||||||
# Usar .copy() para no modificar DEFAULTS accidentalmente
|
# Usar .copy() para no modificar DEFAULTS accidentalmente
|
||||||
bind_vars.update(settings_constants.DEFAULTS.copy())
|
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):
|
if os.path.exists(config_json):
|
||||||
try:
|
try:
|
||||||
with open(config_json, "r") as f:
|
with open(config_json, "r") as f:
|
||||||
@@ -246,17 +250,17 @@ def generate_hyprconf() -> str:
|
|||||||
is_vertical = bar_position in ["Left", "Right"]
|
is_vertical = bar_position in ["Left", "Right"]
|
||||||
animation_type = "slidefadevert" if is_vertical else "slidefade"
|
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 = pgrep -x "hypridle" > /dev/null || uwsm app -- hypridle
|
||||||
exec = uwsm app -- swww-daemon
|
exec = uwsm app -- swww-daemon
|
||||||
exec-once = wl-paste --type text --watch cliphist store
|
exec-once = wl-paste --type text --watch cliphist store
|
||||||
exec-once = wl-paste --type image --watch cliphist store
|
exec-once = wl-paste --type image --watch cliphist store
|
||||||
|
|
||||||
$fabricSend = fabric-cli exec {APP_NAME}
|
$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}
|
# 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
|
# Message
|
||||||
bind = {bind_vars.get("prefix_msg", "SUPER")}, {bind_vars.get("suffix_msg", "A")}, exec, $Message
|
bind = {bind_vars.get("prefix_msg", "SUPER")}, {bind_vars.get("suffix_msg", "A")}, exec, $Message
|
||||||
# Application Switcher
|
# Application Switcher
|
||||||
@@ -279,7 +283,7 @@ bind = {bind_vars.get("prefix_power", "SUPER")}, {bind_vars.get("suffix_power",
|
|||||||
# Toggle Caffeine
|
# 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)"
|
bind = {bind_vars.get("prefix_caffeine", "SUPER SHIFT")}, {bind_vars.get("suffix_caffeine", "M")}, exec, $fabricSend "launcher.show_launcher('caffeine on', external=True)"
|
||||||
# Settings
|
# 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
|
# 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
|
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
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ if __name__ == "__main__":
|
|||||||
current_wallpaper = os.path.expanduser("~/.current.wall")
|
current_wallpaper = os.path.expanduser("~/.current.wall")
|
||||||
if not os.path.exists(current_wallpaper):
|
if not os.path.exists(current_wallpaper):
|
||||||
example_wallpaper = os.path.expanduser(
|
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)
|
os.symlink(example_wallpaper, current_wallpaper)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user