update
This commit is contained in:
14 files changed
+570
-58
No files matched your search
+47
-50
@@ -1,51 +1,18 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
import gi
|
||||
from fabric.utils.helpers import get_relative_path
|
||||
from gi.repository import Gdk, GLib
|
||||
from fabric.utils import Gdk, GLib, get_relative_path, os
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from services.config import start_config_service
|
||||
from utils.functions import parse_timeout_string
|
||||
|
||||
APP_NAME = "modus1"
|
||||
APP_NAME_CAP = "Modus"
|
||||
|
||||
|
||||
def parse_timeout_string(timeout_str):
|
||||
"""
|
||||
Parse timeout string in format like '5s', '10m', '30s' etc.
|
||||
Returns timeout in milliseconds.
|
||||
"""
|
||||
if not timeout_str or not isinstance(timeout_str, str):
|
||||
return 5000
|
||||
|
||||
timeout_str = timeout_str.strip().lower()
|
||||
|
||||
if timeout_str.endswith("s"):
|
||||
try:
|
||||
seconds = int(timeout_str[:-1])
|
||||
return seconds * 1000
|
||||
except ValueError:
|
||||
return 5000
|
||||
elif timeout_str.endswith("m"):
|
||||
try:
|
||||
minutes = int(timeout_str[:-1])
|
||||
return minutes * 60 * 1000
|
||||
except ValueError:
|
||||
return 5000
|
||||
else:
|
||||
try:
|
||||
seconds = int(timeout_str)
|
||||
return seconds * 1000
|
||||
except ValueError:
|
||||
return 5000
|
||||
|
||||
|
||||
CACHE_DIR = str(GLib.get_user_cache_dir()) + f"/{APP_NAME}"
|
||||
|
||||
USERNAME = os.getlogin()
|
||||
HOSTNAME = os.uname().nodename
|
||||
HOME_DIR = os.path.expanduser("~")
|
||||
HOME_DIR = GLib.get_home_dir()
|
||||
|
||||
CONFIG_DIR = os.path.expanduser(f"~/.config/{APP_NAME}")
|
||||
|
||||
@@ -55,22 +22,27 @@ CURRENT_HEIGHT = screen.get_height()
|
||||
|
||||
|
||||
WALLPAPERS_DIR_DEFAULT = get_relative_path("../assets/wallpapers_example/")
|
||||
CONFIG_FILE = get_relative_path("../config/assets/config.json")
|
||||
CONFIG_FILE = get_relative_path("../config.json")
|
||||
MATUGEN_STATE_FILE = os.path.join(CONFIG_DIR, "matugen")
|
||||
|
||||
|
||||
def load_config():
|
||||
"""Load the configuration from config.json"""
|
||||
config = {}
|
||||
try:
|
||||
service = start_config_service()
|
||||
return service.get_all()
|
||||
except ImportError:
|
||||
# Fallback to direct file loading
|
||||
config = {}
|
||||
|
||||
if os.path.exists(CONFIG_FILE):
|
||||
try:
|
||||
with open(CONFIG_FILE, "r") as f:
|
||||
config = json.load(f)
|
||||
except Exception as e:
|
||||
print(f"Error loading config: {e}")
|
||||
if os.path.exists(CONFIG_FILE):
|
||||
try:
|
||||
with open(CONFIG_FILE, "r") as f:
|
||||
config = json.load(f)
|
||||
except Exception as e:
|
||||
print(f"Error loading config: {e}")
|
||||
|
||||
return config
|
||||
return config
|
||||
|
||||
|
||||
if os.path.exists(CONFIG_FILE):
|
||||
@@ -79,7 +51,6 @@ if os.path.exists(CONFIG_FILE):
|
||||
wallpapers_dir_from_config = config.get("wallpapers_dir", WALLPAPERS_DIR_DEFAULT)
|
||||
WALLPAPERS_DIR = os.path.expanduser(wallpapers_dir_from_config)
|
||||
DOCK_POSITION = config.get("dock_position", "Bottom")
|
||||
TERMINAL_COMMAND = config.get("terminal_command", "kitty -e")
|
||||
DOCK_ENABLED = config.get("dock_enabled", True)
|
||||
DOCK_AUTO_HIDE = config.get("dock_auto_hide", True)
|
||||
DOCK_ALWAYS_OCCLUDED = config.get("dock_always_occluded", False)
|
||||
@@ -99,15 +70,27 @@ if os.path.exists(CONFIG_FILE):
|
||||
"notification_limited_apps_history", ["Spotify"]
|
||||
)
|
||||
|
||||
PANEL_COMPONENTS_VISIBILITY = {
|
||||
"imac_button": config.get("imac_button_visible", True),
|
||||
"systray": config.get("systray_visible", True),
|
||||
"control_center": config.get("control_center_visible", True),
|
||||
"search": config.get("search_visible", True),
|
||||
"global_menu": config.get("global_menu_visible", True),
|
||||
"network": config.get("network_visible", True),
|
||||
"battery": config.get("battery_visible", True),
|
||||
"notification_center": config.get("notification_center_visible", True),
|
||||
"workspace_indicator": config.get("workspace_indicator_visible", True),
|
||||
"bluetooth": config.get("bluetooth_visible", True),
|
||||
"date_time": config.get("date_time_visible", True),
|
||||
}
|
||||
|
||||
else:
|
||||
WALLPAPERS_DIR = WALLPAPERS_DIR_DEFAULT
|
||||
DOCK_POSITION = "Bottom"
|
||||
DOCK_ENABLED = True
|
||||
DOCK_ALWAYS_OCCLUDED = False
|
||||
DOCK_AUTO_HIDE = True
|
||||
TERMINAL_COMMAND = "kitty -e"
|
||||
DOCK_THEME = "Pills"
|
||||
DOCK_ICON_SIZE = 60
|
||||
DOCK_ICON_SIZE = 52
|
||||
WINDOW_SWITCHER_ITEMS_PER_ROW = 10
|
||||
HIDE_SPECIAL_WORKSPACE = True
|
||||
DOCK_HIDE_SPECIAL_WORKSPACE_APPS = True
|
||||
@@ -116,3 +99,17 @@ else:
|
||||
NOTIFICATION_TIMEOUT = parse_timeout_string(NOTIFICATION_TIMEOUT_STR)
|
||||
NOTIFICATION_IGNORED_APPS_HISTORY = ["Hyprshot"]
|
||||
NOTIFICATION_LIMITED_APPS_HISTORY = ["Spotify"]
|
||||
|
||||
PANEL_COMPONENTS_VISIBILITY = {
|
||||
"imac_button": True,
|
||||
"systray": True,
|
||||
"control_center": True,
|
||||
"search": True,
|
||||
"global_menu": True,
|
||||
"network": True,
|
||||
"battery": True,
|
||||
"notification_center": True,
|
||||
"workspace_indicator": True,
|
||||
"bluetooth": True,
|
||||
"date_time": True,
|
||||
}
|
||||
Reference in new issue
Block a user