This commit is contained in:
sankalp committed 2026-07-12 18:56:10 +05:45
1 parent 6b62051f93
commit dc60e20bd7
182 files changed
+18062 -277

No files matched your search

+151
View File
@@ -0,0 +1,151 @@
from fabric.utils import Gdk, GLib, get_relative_path, logger, os
from utils.constants import DEFAULT
from utils.functions import read_json_file, write_json_file
APP_NAME = "modus"
APP_NAME_CAP = "Modus"
HOME_DIR = GLib.get_home_dir()
CACHE_DIR = f"{GLib.get_user_cache_dir()}/{APP_NAME}"
os.makedirs(CACHE_DIR, exist_ok=True)
ICON_CACHE_FILE = f"{CACHE_DIR}/icons.json"
CONFIG_FILE = get_relative_path("../config.json")
SYSTEM_CACHE_DIR = GLib.get_user_cache_dir()
WALLPAPER_PATH = f"{HOME_DIR}/Pictures/Wallpapers"
WALLPAPER_THUMBS_PATH = f"{WALLPAPER_PATH}/.thumbnails"
WALLPAPERS_THUMBNAILS_SIZE = 200
RECENT_EMOJIS_FILE = f"{CACHE_DIR}/recent_emojis.json"
# Matugen template and output paths
MATUGEN_TEMPLATE_PATH = get_relative_path("../config/matugen/templates/modus.css")
MATUGEN_OUTPUT_PATH = get_relative_path("../styles/colors.css")
CLIPBOARD_THUMBS_DIR = f"{GLib.get_user_cache_dir()}/{APP_NAME}/clipboard_thumbs"
CLIPBOARD_DB_PATH = f"{GLib.get_user_cache_dir()}/cliphist/db"
plugins = f"{GLib.get_user_state_dir()}/{APP_NAME}"
screen = Gdk.Screen.get_default()
CURRENT_WIDTH = screen.get_width()
CURRENT_HEIGHT = screen.get_height()
def generate_default_config():
"""Generate default config.json file if it doesn't exist"""
if not os.path.exists(CONFIG_FILE):
write_json_file(DEFAULT, CONFIG_FILE)
logger.success("Config file generated successfully")
def DATA():
config = read_json_file(CONFIG_FILE) or {}
debug = config.get("debug", {})
panel = config.get("panel", {})
corners = config.get("corners", {})
wallpaper_dir = config.get("wallpaper_dir", {})
osd = config.get("osd", {})
notifications = config.get("notifications", {})
keyboard_layout = config.get("keyboard_layout", {})
return {
"debug": debug.get("enabled"),
"wallpaper_dir": wallpaper_dir.get("path"),
"corners": corners.get("enabled"),
"panel_enabled": panel.get("enabled"),
"panel_autohide": panel.get("autohide"),
"panel_position": panel.get("position"),
"systray": panel.get("systray", {}).get("enabled"),
"systray_hide_icons": panel.get("systray", {}).get("hide_items", []),
"datetime": panel.get("datetime", {}).get("enabled"),
"datetime_12hrs": panel.get("datetime", {}).get("12hrs"),
"battery": panel.get("battery", {}).get("enabled"),
"battery_label": panel.get("battery", {}).get("label"),
"battery_hide_on_full": panel.get("battery", {}).get("hide_on_full"),
"battery_icon_size": panel.get("battery", {}).get("icon_size", 16),
"network": panel.get("network", {}).get("enabled"),
"bluetooth": panel.get("bluetooth", {}).get("enabled"),
"workspace": panel.get("workspace", {}).get("enabled"),
"workspace_hide_special": panel.get("workspace", {}).get("hide_special_ws"),
"taskbar": panel.get("taskbar", {}).get("enabled"),
"taskbar_icon_size": panel.get("taskbar", {}).get("icon_size"),
"taskbar_hide_empty": panel.get("taskbar", {}).get("hide_empty"),
"taskbar_hide_special": panel.get("taskbar", {}).get("hide_special"),
"taskbar_group_apps": panel.get("taskbar", {}).get("group_apps"),
"osd": osd.get("enabled"),
"osd_audio": osd.get("audio"),
"osd_brightness": osd.get("brightness"),
"osd_capslock": osd.get("capslock"),
"osd_kb_layout": osd.get("kb_layout"),
"osd_network": osd.get("network"),
"osd_microphone": osd.get("microphone"),
"osd_battery": osd.get("battery"),
"osd_cooldown_ms": osd.get("cooldown_ms"),
"osd_position": osd.get("position"),
"notifications": notifications.get("enabled"),
"notifications_timeout": notifications.get("timeout"),
"notifications_image_size": notifications.get("image_size"),
"notifications_width": notifications.get("width"),
"notifications_buttons_per_row": notifications.get("buttons_per_row"),
"notifications_enabled": notifications.get("enabled"),
"notifications_corner_size": notifications.get("corner_size"),
"notifications_revealer_duration": notifications.get("revealer_duration"),
"keyboard_layouts": keyboard_layout.get("layouts", ["us", "np"]),
}
def update_setting(key: str, value) -> bool:
"""Update a specific setting in config.json."""
config = read_json_file(CONFIG_FILE) or {}
key_map = {
"osd": ("osd", "enabled"),
"osd_position": ("osd", "position"),
"osd_audio": ("osd", "audio"),
"osd_brightness": ("osd", "brightness"),
"osd_capslock": ("osd", "capslock"),
"osd_kb_layout": ("osd", "kb_layout"),
"osd_network": ("osd", "network"),
"osd_microphone": ("osd", "microphone"),
"osd_battery": ("osd", "battery"),
"panel_enabled": ("panel", "enabled"),
"panel_position": ("panel", "position"),
"panel_autohide": ("panel", "autohide"),
"systray": ("panel", "systray", "enabled"),
"systray_hide_icons": ("panel", "systray", "hide_items"),
"network": ("panel", "network", "enabled"),
"bluetooth": ("panel", "bluetooth", "enabled"),
"datetime": ("panel", "datetime", "enabled"),
"datetime_12hrs": ("panel", "datetime", "12hrs"),
"battery": ("panel", "battery", "enabled"),
"battery_label": ("panel", "battery", "label"),
"battery_hide_on_full": ("panel", "battery", "hide_on_full"),
"workspace": ("panel", "workspace", "enabled"),
"workspace_hide_special": ("panel", "workspace", "hide_special_ws"),
"taskbar": ("panel", "taskbar", "enabled"),
"taskbar_hide_empty": ("panel", "taskbar", "hide_empty"),
"notifications": ("notifications", "enabled"),
"wallpaper_dir": ("wallpaper_dir", "path"),
"corners": ("corners", "enabled"),
"debug": ("debug", "enabled"),
}
if key not in key_map:
logger.warning(f"Unknown setting key: {key}")
return False
path = key_map[key]
if len(path) == 2:
if path[0] not in config:
config[path[0]] = {}
config[path[0]][path[1]] = value
elif len(path) == 3:
if path[0] not in config:
config[path[0]] = {}
if path[1] not in config[path[0]]:
config[path[0]][path[1]] = {}
config[path[0]][path[1]][path[2]] = value
write_json_file(config, CONFIG_FILE)
return True
+152
View File
@@ -0,0 +1,152 @@
local modus = "/home/sankalp/.config/Modus"
hl.on("hyprland.start", function()
local cmds = {
"uwsm app -- awww-daemon",
"wl-paste --type text --watch cliphist store",
"wl-paste --type image --watch cliphist store",
"pgrep -x hypridle >/dev/null || uwsm app -- hypridle",
"cd " .. modus .. " && uwsm app -- uv run main.py",
}
for i = 1, #cmds do
local cmd = cmds[i]
hl.exec_cmd(cmd)
end
end)
local fabricSend = "uwsm app -- fabric-cli exec modus "
-- notification testing
for key, cmd in pairs({
["ALT + F12"] = 'notify-send \'Test notification\' "Here\'s a really long message to test truncation and wrapping\\nYou can middle click or flick this notification to dismiss it!" -a \'terminal\' -A "Test1=I got it!" -A "Test2=Another action"',
["ALT + Equal"] = "notify-send 'hmm' ${SLURP_ARGS}",
["SHIFT + ALT + N"] = 'notify-send "Hello" "FIRE IN THE HOLE‼️🗣️🔥🕳️" -i "/home/sankalp/.face.icon" -A "🗣️" -A "🔥" -A "🕳️" -a "Source Code"',
}) do
hl.bind(key, hl.dsp.exec_cmd(cmd))
end
-- Reload Modus
hl.bind("ALT + SHIFT + R", hl.dsp.exec_cmd("killall modus; cd " .. modus .. " && uwsm app -- uv run main.py"))
-- Fabric Launcher Binds
for key, method in pairs({
["SUPER + D"] = "launcher.toggle()", -- Launcher
["SUPER + E"] = "launcher.toggle('em')", -- Emoji
["SUPER + V"] = "launcher.toggle('clip')", -- Clipboard
["SUPER + W"] = "launcher.toggle('wall')", -- Wallpaper
["SUPER + X"] = "launcher.toggle('pm')", -- Powermenu
["SUPER + Z"] = "launcher.toggle('sc')", -- Screencapture
["SUPER + O"] = "launcher.toggle('otp')", -- OTP
["SUPER + SHIFT + P"] = "launcher.toggle('pass')", -- Password Manager
["SUPER + S"] = "launcher.toggle('sc region', external=True)", -- Screenshot region
["ALT + SHIFT + W"] = "launcher.toggle('wr', external=True)", -- Random Wallpaper
["SUPER + G"] = "launcher.toggle('gg')", -- Google Search
["ALT + W"] = "launcher.toggle('win')", -- Window Switcher
["SUPER + T"] = "launcher.toggle('tmux')", -- Tmux
["ALT + SPACE"] = "switch_keyboard_layout()", -- KB_Layout Switcher
}) do
hl.bind(key, hl.dsp.exec_cmd(fabricSend .. '"' .. method .. '"'))
end
-- Audio keys
for key, cmd in pairs({
AudioRaiseVolume = "wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+",
AudioLowerVolume = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-",
AudioMute = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle",
AudioMicMute = "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle",
}) do
hl.bind(
"XF86" .. key,
hl.dsp.exec_cmd(cmd .. " && " .. fabricSend .. '"osd_show_audio()"'),
{ locked = true, repeating = true }
)
end
-- Brightness keys
for key, cmd in pairs({
MonBrightnessUp = "brightnessctl -e4 -n2 set 5%+",
MonBrightnessDown = "brightnessctl -e4 -n2 set 5%-",
}) do
hl.bind(
"XF86" .. key,
hl.dsp.exec_cmd(cmd .. " && " .. fabricSend .. '"osd_show_brightness()"'),
{ locked = true, repeating = true }
)
end
hl.layer_rule({
match = {
namespace = "fabric",
},
no_anim = true,
})
local colors = dofile(modus .. "/config/hypr/colors.lua")
hl.config({
general = {
col = {
active_border = colors.primary,
inactive_border = colors.surface,
},
gaps_in = 2,
gaps_out = 4,
border_size = 2,
layout = "scrolling",
},
decoration = {
blur = {
enabled = false,
size = 5,
passes = 3,
new_optimizations = true,
contrast = 1,
brightness = 1,
},
rounding = 14,
shadow = {
enabled = false,
range = 10,
render_power = 2,
color = "rgba(0, 0, 0, 0.25)",
},
},
animations = {
enabled = true,
},
})
-- Curves
hl.curve("expressiveFastSpatial", { type = "bezier", points = { { 0.42, 1.67 }, { 0.21, 0.90 } } })
hl.curve("expressiveSlowSpatial", { type = "bezier", points = { { 0.39, 1.29 }, { 0.35, 0.98 } } })
hl.curve("expressiveDefaultSpatial", { type = "bezier", points = { { 0.38, 1.21 }, { 0.22, 1.00 } } })
hl.curve("emphasizedDecel", { type = "bezier", points = { { 0.05, 0.7 }, { 0.1, 1 } } })
hl.curve("emphasizedAccel", { type = "bezier", points = { { 0.3, 0 }, { 0.8, 0.15 } } })
hl.curve("standardDecel", { type = "bezier", points = { { 0, 0 }, { 0, 1 } } })
hl.curve("menu_decel", { type = "bezier", points = { { 0.1, 1 }, { 0, 1 } } })
hl.curve("menu_accel", { type = "bezier", points = { { 0.52, 0.03 }, { 0.72, 0.08 } } })
hl.curve("stall", { type = "bezier", points = { { 1, -0.1 }, { 0.7, 0.85 } } })
-- Configs
-- Animations
local animations = {
-- leaf, speed, bezier, style
{ "windowsIn", 3, "emphasizedDecel", "popin 80%" },
{ "fadeIn", 3, "emphasizedDecel" },
{ "windowsOut", 2, "emphasizedDecel", "popin 90%" },
{ "fadeOut", 2, "emphasizedDecel" },
{ "windowsMove", 3, "emphasizedDecel", "slide" },
{ "border", 10, "emphasizedDecel" },
{ "layersIn", 2.7, "emphasizedDecel", "popin 93%" },
{ "layersOut", 2.4, "menu_accel", "popin 94%" },
{ "fadeLayersIn", 0.5, "menu_decel" },
{ "fadeLayersOut", 2.7, "stall" },
{ "workspaces", 7, "menu_decel", "slide" },
{ "specialWorkspaceIn", 2.8, "emphasizedDecel", "slidevert" },
{ "specialWorkspaceOut", 1.2, "emphasizedAccel", "slidevert" },
{ "zoomFactor", 3, "standardDecel" },
}
for _, anim in ipairs(animations) do
hl.animation({ leaf = anim[1], enabled = true, speed = anim[2], bezier = anim[3], style = anim[4] })
end
@@ -0,0 +1,5 @@
return {
<* for name, value in colors *>
{{name}} = "rgb({{value.default.hex_stripped}})",
<* endfor *>
}
+32
View File
@@ -0,0 +1,32 @@
:vars {
--foreground: {{colors.on_background.default.hex}};
--background: {{colors.background.default.hex}};
--cursor: {{colors.on_background.default.hex}};
--primary: {{colors.primary.default.hex}};
--on-primary: {{colors.on_primary.default.hex}};
--secondary: {{colors.secondary.default.hex}};
--on-secondary: {{colors.on_secondary.default.hex}};
--tertiary: {{colors.tertiary.default.hex}};
--on-tertiary: {{colors.on_tertiary.default.hex}};
--surface: {{colors.surface.default.hex}};
--surface-bright: {{colors.surface_bright.default.hex}};
--error: {{colors.error.default.hex}};
--error-dim: {{colors.error.default.hex | set_lightness: -10.0}};
--on-error: {{colors.on_error.default.hex}};
--error-container: {{colors.error_container.default.hex}};
--outline: {{colors.outline.default.hex}};
--shadow: {{colors.shadow.default.hex}};
--red: {{colors.red.default.hex}};
--red-dim: {{colors.red.default.hex | set_lightness: -10.0}};
--green: {{colors.green.default.hex}};
--green-dim: {{colors.green.default.hex | set_lightness: -10.0}};
--yellow: {{colors.yellow.default.hex}};
--yellow-dim: {{colors.yellow.default.hex | set_lightness: -10.0}};
--blue: {{colors.blue.default.hex}};
--blue-dim: {{colors.blue.default.hex | set_lightness: -10.0}};
--magenta: {{colors.magenta.default.hex}};
--magenta-dim: {{colors.magenta.default.hex | set_lightness: -10.0}};
--cyan: {{colors.cyan.default.hex}};
--cyan-dim: {{colors.cyan.default.hex | set_lightness: -10.0}};
--white: {{colors.white.default.hex}};
}