added styles
This commit is contained in:
1 parent
b9b3c57006
commit
18e38a9f61
18 files changed
+497
-290
No files matched your search
+22
-5
@@ -1,10 +1,10 @@
|
||||
import os
|
||||
|
||||
import setproctitle
|
||||
from loguru import logger
|
||||
|
||||
from fabric import Application
|
||||
from fabric.utils import get_relative_path, monitor_file
|
||||
from loguru import logger
|
||||
|
||||
from modules.bar.bar import Bar
|
||||
from modules.launcher.launcher import Launcher
|
||||
from modules.notification_popup import NotificationPopup
|
||||
@@ -14,18 +14,34 @@ from services import ScreenRecorder
|
||||
logger.disable("fabric.hyprland.widgets")
|
||||
|
||||
|
||||
def update_main_css():
|
||||
colors_css_path = f"/home/{os.getlogin()}/.cache/material/colors.css"
|
||||
main_css_path = get_relative_path("styles/main.css")
|
||||
|
||||
if os.path.exists(colors_css_path):
|
||||
logger.info(f"[Main] Updating colors.css path in {main_css_path}")
|
||||
with open(main_css_path, "r+") as css_file:
|
||||
content = css_file.read()
|
||||
updated_content = content.replace("@COLORS_CSS_PATH", colors_css_path)
|
||||
css_file.seek(0)
|
||||
css_file.write(updated_content)
|
||||
css_file.truncate()
|
||||
else:
|
||||
logger.warning(f"[Main] colors.css not found at {colors_css_path}")
|
||||
|
||||
|
||||
def apply_style(app: Application):
|
||||
logger.info("[Main] CSS applied")
|
||||
logger.info("[Main] Applying CSS")
|
||||
app.set_stylesheet_from_file(get_relative_path("styles/main.css"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
update_main_css()
|
||||
sc = ScreenRecorder()
|
||||
bar = Bar()
|
||||
osd = OSDContainer()
|
||||
notif = NotificationPopup()
|
||||
launcher = Launcher()
|
||||
launcher.hide()
|
||||
|
||||
app = Application(
|
||||
"quickbar",
|
||||
@@ -35,12 +51,13 @@ if __name__ == "__main__":
|
||||
)
|
||||
setproctitle.setproctitle("quickbar")
|
||||
|
||||
# Monitor CSS files for changes
|
||||
css_file = monitor_file(get_relative_path("styles"))
|
||||
_ = css_file.connect("changed", lambda *_: apply_style(app))
|
||||
|
||||
color_css_file = monitor_file(f"/home/{os.getlogin()}/.cache/material/colors.css")
|
||||
_ = color_css_file.connect("changed", lambda *_: apply_style(app))
|
||||
|
||||
# Apply the styles and run the application
|
||||
apply_style(app)
|
||||
|
||||
app.run()
|
||||
@@ -86,20 +86,25 @@
|
||||
}
|
||||
|
||||
menu {
|
||||
border: solid 1px @outlineVariant;
|
||||
border-radius: 16px;
|
||||
background-color: @surfaceContainer;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
menu > menuitem {
|
||||
border-radius: 12px;
|
||||
padding: 10px;
|
||||
margin-left: 2px;
|
||||
margin-right: 2px;
|
||||
border-radius: 10px;
|
||||
padding: 6px 10px;
|
||||
}
|
||||
|
||||
menu > menuitem:hover {
|
||||
background-color: mix(@onSurface, @surface, 0.85);
|
||||
}
|
||||
|
||||
menu > menuitem:hover > label {
|
||||
color: @onSurface;
|
||||
}
|
||||
|
||||
/*
|
||||
* ── applets ───────────────────────────────────────────────────────────
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
background-color: @surface;
|
||||
border-radius: 24px;
|
||||
padding: 18px;
|
||||
min-width: 480px;
|
||||
transition: all 0.5s cubic-bezier(0.5, 0.25, 0, 1);
|
||||
}
|
||||
|
||||
#launcher entry {
|
||||
@@ -28,159 +28,26 @@
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
#profile-pic {
|
||||
background-color: transparent;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
#launcher-content.wallpapers {
|
||||
padding: 16px;
|
||||
min-height: 420px;
|
||||
min-width: 620px;
|
||||
}
|
||||
|
||||
#app-launcher,
|
||||
#wallpapers,
|
||||
#power-menu {
|
||||
transition: all 0.25s cubic-bezier(0.5, 0.25, 0, 1);
|
||||
}
|
||||
|
||||
#close-button {
|
||||
background-color: @surface;
|
||||
border-radius: 100px;
|
||||
padding: 20px;
|
||||
margin: 4px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#launcher button#app-item {
|
||||
border-radius: 11px;
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
box-shadow: none;
|
||||
transition: 200ms;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
#launcher button#app-item:hover #title,
|
||||
#launcher button#app-item:focus #title {
|
||||
color: @primar;
|
||||
}
|
||||
|
||||
#launcher button#app-item:hover #description,
|
||||
#launcher button#app-item:focus #description {
|
||||
color: @inversePrimary;
|
||||
}
|
||||
|
||||
#launcher button#app-item:hover image,
|
||||
#launcher button#app-item:focus image {
|
||||
-gtk-icon-shadow: 2px 2px @primary;
|
||||
}
|
||||
|
||||
#launcher button#app-item:active {
|
||||
background-color: @primaryContainer;
|
||||
border-radius: 11px;
|
||||
box-shadow: inset 0 0 0 1px rgba(158, 142, 130, 0.04);
|
||||
}
|
||||
|
||||
#launcher button#app-item:active #title {
|
||||
color: @foreground;
|
||||
}
|
||||
|
||||
#launcher button#emoji-item {
|
||||
border-radius: 11px;
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
box-shadow: none;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#launcher button#emoji-item:disabled {
|
||||
color: mix(@onSurface, transparent, 0.38);
|
||||
}
|
||||
|
||||
#launcher button#emoji-item label {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
#launcher button#emoji-item:hover,
|
||||
#launcher button#emoji-item:focus {
|
||||
text-shadow: 2px 2px 2px @primary;
|
||||
}
|
||||
|
||||
#launcher button#cliphist-img-item {
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
border-radius: 8px;
|
||||
min-width: 70px;
|
||||
min-height: 70px;
|
||||
}
|
||||
|
||||
#launcher button#cliphist-img-item:hover,
|
||||
#launcher button#cliphist-img-item:focus {
|
||||
box-shadow: 2px 2px 2px @primary;
|
||||
}
|
||||
|
||||
#launcher button#launcher-item {
|
||||
border-radius: 11px;
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#launcher button#launcher-item:disabled {
|
||||
color: mix(@onSurface, transparent, 0.38);
|
||||
}
|
||||
|
||||
#launcher button#launcher-item:hover,
|
||||
#launcher button#launcher-item:focus {
|
||||
text-shadow: 2pt 2pt 2pt @primary;
|
||||
}
|
||||
|
||||
#launcher button#wall-item {
|
||||
border-radius: 0px;
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
box-shadow: none;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#launcher button#wall-item:disabled {
|
||||
color: mix(@onSurface, transparent, 0.38);
|
||||
}
|
||||
|
||||
#launcher button#wall-item:hover,
|
||||
#launcher button#wall-item:focus {
|
||||
box-shadow: 2pt 2pt 2pt @primary;
|
||||
}
|
||||
|
||||
.activated {
|
||||
background-color: @surfaceVariant;
|
||||
#close-button:hover,
|
||||
#close-button:focus {
|
||||
border-radius: 100px;
|
||||
}
|
||||
|
||||
#calendar calendar {
|
||||
all: unset;
|
||||
font-size: 18px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#calendar calendar.button {
|
||||
all: unset;
|
||||
transition: 200ms;
|
||||
border-radius: 10px;
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#calendar calendar:selected {
|
||||
box-shadow:
|
||||
inset 0 -7px 0 0 @primary,
|
||||
inset 0 0 0 1px @surfaceVariant;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
#calendar calendar.header {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#calendar calendar.highlight {
|
||||
background-color: transparent;
|
||||
color: @onSurface;
|
||||
}
|
||||
|
||||
#calendar calendar:hover {
|
||||
color: @errorContainer;
|
||||
}
|
||||
|
||||
#calendar calendar:indeterminate {
|
||||
color: mix(@onSurfaceVariant, transparent, 0.3);
|
||||
background-color: @errorContainer;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#app-slot-button {
|
||||
border-radius: 16px;
|
||||
padding: 16px;
|
||||
transition: padding 0.25s cubic-bezier(0.5, 0.25, 0, 1);
|
||||
animation: loadSlot 0.5s ease;
|
||||
}
|
||||
|
||||
@keyframes loadSlot {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
#app-slot-button:hover,
|
||||
#app-slot-button:focus {
|
||||
background-color: mix(@onSurface, @surface, 0.92);
|
||||
padding-left: 24px;
|
||||
}
|
||||
|
||||
#app-slot-button:active {
|
||||
background-color: @primaryContainer;
|
||||
}
|
||||
|
||||
#app-label {
|
||||
color: @onSurface;
|
||||
}
|
||||
|
||||
#wallpaper-icons {
|
||||
animation: fade-in 0.25s ease-in-out;
|
||||
}
|
||||
|
||||
@keyframes fade-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,29 @@
|
||||
#cliphist-launcher-box button#clip-img-item {
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
border-radius: 8px;
|
||||
min-width: 70px;
|
||||
min-height: 70px;
|
||||
}
|
||||
|
||||
#cliphist-launcher-box button#clip-img-item:hover,
|
||||
#cliphist-launcher-box button#clip-img-item:focus {
|
||||
box-shadow: 2px 2px 2px @primary;
|
||||
}
|
||||
|
||||
#cliphist-launcher-box button#clip-item {
|
||||
border-radius: 11px;
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
box-shadow: none;
|
||||
padding: 7px;
|
||||
}
|
||||
#cliphist-launcher-box button#clip-item {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
#cliphist-launcher-box button#clip-item:hover,
|
||||
#cliphist-launcher-box button#clip-item:focus {
|
||||
text-shadow: 2px 2px 2px @primary;
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,16 @@
|
||||
#emoji-launcher-box button#emoji-item {
|
||||
border-radius: 11px;
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
box-shadow: none;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#emoji-launcher-box button#emoji-item label {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
#emoji-launcher-box button#emoji-item:hover,
|
||||
#emoji-launcher-box button#emoji-item:focus {
|
||||
text-shadow: 2px 2px 2px @primary;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#power-menu-button {
|
||||
border-radius: 20px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#power-menu-button:hover,
|
||||
#power-menu-button:focus {
|
||||
background-color: mix(@onSurface, @surface, 0.8);
|
||||
}
|
||||
|
||||
#power-menu-button:hover label,
|
||||
#power-menu-button:focus label {
|
||||
color: @primary;
|
||||
}
|
||||
|
||||
#power-menu-button:active {
|
||||
background-image: radial-gradient(
|
||||
circle,
|
||||
mix(@onSurfaceVariant, transparent, 0.7) 10%,
|
||||
transparent 0%
|
||||
);
|
||||
}
|
||||
|
||||
#power-menu-button:active label {
|
||||
color: @shadow;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#todo-launcher {
|
||||
background-color: @surface;
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
#todo-item {
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
background-color: alpha(@surface, 0.8);
|
||||
}
|
||||
|
||||
#todo-label {
|
||||
color: @primary;
|
||||
}
|
||||
|
||||
#todo-label-completed {
|
||||
color: alpha(@outlineVariant, 0.5);
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
#delete-button {
|
||||
color: @error;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#wallpaper-icons {
|
||||
animation: fade-in 0.25s ease-in-out;
|
||||
}
|
||||
|
||||
@keyframes fade-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
#wallpaper-icons:selected {
|
||||
background-color: @primary;
|
||||
color: @background;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
#dropdown-box {
|
||||
background-color: @surface;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#scheme-dropdown {
|
||||
font-weight: bold;
|
||||
}
|
||||
Whitespace-only changes.
@@ -1,8 +1,14 @@
|
||||
@import url(/home/sankalp/.cache/material/colors.css);
|
||||
@import "./launcher.css";
|
||||
@import url(../../.cache/material/colors.css);
|
||||
@import "./bar.css";
|
||||
@import "./notification.css";
|
||||
@import "./osd.css";
|
||||
@import "./launcher.css";
|
||||
@import "./launcher/applauncher.css";
|
||||
@import "./launcher/wallpapers.css";
|
||||
@import "./launcher/powermenu.css";
|
||||
@import "./launcher/todo.css";
|
||||
@import "./launcher/emoji.css";
|
||||
@import "./launcher/cliphist.css";
|
||||
|
||||
* {
|
||||
all: unset;
|
||||
|
||||
@@ -41,7 +41,7 @@ def join(*args):
|
||||
return os.path.join(*args)
|
||||
|
||||
|
||||
home = os.path.expanduser("~")
|
||||
home = os.path.expanduser('~')
|
||||
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
cache_path = f"{home}/.cache/material/"
|
||||
@@ -49,14 +49,14 @@ os.makedirs(cache_path, exist_ok=True)
|
||||
|
||||
|
||||
def rgb_to_hex(rgb):
|
||||
return "#{:02x}{:02x}{:02x}".format(*rgb[:3])
|
||||
return '#{:02x}{:02x}{:02x}'.format(*rgb[:3])
|
||||
|
||||
|
||||
def rgba_to_rgb(rgba):
|
||||
return f"{rgba[0]}, {rgba[1]}, {rgba[2]}"
|
||||
return f'{rgba[0]}, {rgba[1]}, {rgba[2]}'
|
||||
|
||||
|
||||
class Color:
|
||||
class Color():
|
||||
def __init__(self, scheme) -> None:
|
||||
self.scheme = scheme
|
||||
|
||||
@@ -70,12 +70,8 @@ class Color:
|
||||
|
||||
class ColorsCache:
|
||||
def __init__(
|
||||
self,
|
||||
colors: DynamicScheme | dict,
|
||||
wallpaper: str,
|
||||
original_color: int,
|
||||
contrast_level: int,
|
||||
scheme_name: str,
|
||||
self, colors: DynamicScheme | dict, wallpaper: str,
|
||||
original_color: int, contrast_level: int, scheme_name: str
|
||||
) -> None:
|
||||
self.colors: dict[str, str] = {}
|
||||
self.wallpaper = wallpaper
|
||||
@@ -99,7 +95,7 @@ def colors_dict(cache: ColorsCache):
|
||||
"colors": cache.colors,
|
||||
"original_color": cache.original_color,
|
||||
"contrast_level": cache.contrast_level,
|
||||
"scheme_name": cache.scheme_name,
|
||||
"scheme_name": cache.scheme_name
|
||||
}
|
||||
return dict
|
||||
|
||||
@@ -112,7 +108,10 @@ def get_cache_object(object: dict | str):
|
||||
original_color = object["original_color"]
|
||||
contrast_level = object.get("contrast_level", 0)
|
||||
scheme_name = object.get("scheme_name", "tonalSpot")
|
||||
return ColorsCache(colors, wallpaper, original_color, contrast_level, scheme_name)
|
||||
return ColorsCache(
|
||||
colors, wallpaper, original_color,
|
||||
contrast_level, scheme_name
|
||||
)
|
||||
|
||||
|
||||
def get_file_list(folder_path):
|
||||
@@ -125,9 +124,11 @@ def get_file_list(folder_path):
|
||||
|
||||
ready_templates = {
|
||||
"colors.css": "@define-color {name} {hex};\n",
|
||||
"colors.scss": "${name}: {hex};\n",
|
||||
"colors.scss": "${name}: {hex};\n"
|
||||
}
|
||||
additional = {
|
||||
"onBackground": "foreground"
|
||||
}
|
||||
additional = {"onBackground": "foreground"}
|
||||
|
||||
|
||||
def generate_color_map(scheme: DynamicScheme):
|
||||
@@ -146,23 +147,25 @@ class ColorFormatter:
|
||||
|
||||
def apply_transformations(self, value, transformations):
|
||||
intermediate_transforms = [
|
||||
t for t in transformations if not (t.startswith("strip") or t == "rgb")
|
||||
t for t in transformations
|
||||
if not (t.startswith("strip") or t == "rgb")
|
||||
]
|
||||
final_transforms = [
|
||||
t for t in transformations if t.startswith("strip") or t == "rgb"
|
||||
t for t in transformations
|
||||
if t.startswith("strip") or t == "rgb"
|
||||
]
|
||||
|
||||
for transform in intermediate_transforms:
|
||||
if transform.startswith("lighten"):
|
||||
percent = int(re.search(r"\d+", transform).group())
|
||||
percent = int(re.search(r'\d+', transform).group())
|
||||
value = self.adjust_brightness(value, percent)
|
||||
elif transform.startswith("darken"):
|
||||
percent = int(re.search(r"\d+", transform).group())
|
||||
percent = int(re.search(r'\d+', transform).group())
|
||||
value = self.adjust_brightness(value, -percent)
|
||||
|
||||
for transform in final_transforms:
|
||||
if transform.startswith("strip"):
|
||||
value = value.lstrip("#")
|
||||
value = value.lstrip('#')
|
||||
elif transform == "rgb":
|
||||
value = self.hex_to_rgb(value)
|
||||
|
||||
@@ -172,22 +175,24 @@ class ColorFormatter:
|
||||
def min_max(v):
|
||||
return min(255, max(0, v))
|
||||
|
||||
hex_color = hex_color.lstrip("#")
|
||||
r, g, b = (int(hex_color[i : i + 2], 16) for i in (0, 2, 4))
|
||||
hex_color = hex_color.lstrip('#')
|
||||
r, g, b = (int(hex_color[i:i+2], 16) for i in (0, 2, 4))
|
||||
|
||||
r = min_max(int(r * (1 + factor / 100)))
|
||||
g = min_max(int(g * (1 + factor / 100)))
|
||||
b = min_max(int(b * (1 + factor / 100)))
|
||||
|
||||
return f"#{r:02X}{g:02X}{b:02X}".lower()
|
||||
return f'#{r:02X}{g:02X}{b:02X}'.lower()
|
||||
|
||||
def hex_to_rgb(self, hex_color):
|
||||
hex_color = hex_color.lstrip("#")
|
||||
r, g, b = (int(hex_color[i : i + 2], 16) for i in (0, 2, 4))
|
||||
return f"{r},{g},{b}"
|
||||
hex_color = hex_color.lstrip('#')
|
||||
r, g, b = (int(hex_color[i:i+2], 16) for i in (0, 2, 4))
|
||||
return f'{r},{g},{b}'
|
||||
|
||||
def parse_transformations(self, transformations_str):
|
||||
transformations = re.findall(r"(\w+)(?:\((\d*)\))?", transformations_str)
|
||||
transformations = re.findall(
|
||||
r'(\w+)(?:\((\d*)\))?', transformations_str
|
||||
)
|
||||
result = []
|
||||
for command, arg in transformations:
|
||||
if command:
|
||||
@@ -198,7 +203,7 @@ class ColorFormatter:
|
||||
return result
|
||||
|
||||
def format(self, text):
|
||||
pattern = r"(<(\w+)(?:\.(.+))?>)"
|
||||
pattern = r'(<(\w+)(?:\.(.+))?>)'
|
||||
matches = re.findall(pattern, text)
|
||||
result = []
|
||||
last_end = 0
|
||||
@@ -206,30 +211,27 @@ class ColorFormatter:
|
||||
for match in matches:
|
||||
full_match, key, transformations_str = match
|
||||
if key in self.color_map:
|
||||
result.append(text[last_end : text.find(full_match, last_end)])
|
||||
result.append(text[last_end:text.find(full_match, last_end)])
|
||||
value = self.color_map[key]
|
||||
if transformations_str:
|
||||
transformations = self.parse_transformations(transformations_str)
|
||||
transformations = self.parse_transformations(
|
||||
transformations_str
|
||||
)
|
||||
value = self.apply_transformations(value, transformations)
|
||||
result.append(value)
|
||||
last_end = text.find(full_match, last_end) + len(full_match)
|
||||
|
||||
result.append(text[last_end:])
|
||||
result = "".join(result)
|
||||
pattern = r"<\\\\([^>]+)>"
|
||||
result = ''.join(result)
|
||||
pattern = r'<\\\\([^>]+)>'
|
||||
|
||||
result = re.sub(pattern, r"<\1>", result)
|
||||
result = re.sub(pattern, r'<\1>', result)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def generate_templates(
|
||||
folder: str,
|
||||
output_folder: str,
|
||||
scheme: DynamicScheme,
|
||||
color_scheme: str,
|
||||
wallpaper: str = "",
|
||||
):
|
||||
def generate_templates(folder: str, output_folder: str, scheme: DynamicScheme,
|
||||
color_scheme: str, wallpaper: str = ''):
|
||||
if not os.path.exists(output_folder):
|
||||
os.makedirs(output_folder)
|
||||
if not os.path.exists(folder):
|
||||
@@ -242,12 +244,13 @@ def generate_templates(
|
||||
formatter = ColorFormatter(scheme)
|
||||
template = formatter.format(template)
|
||||
template = (
|
||||
template.replace("<color-scheme>", color_scheme)
|
||||
template
|
||||
.replace("<color-scheme>", color_scheme)
|
||||
.replace("<output-folder>", output_folder)
|
||||
.replace("<wallpaper>", wallpaper)
|
||||
)
|
||||
new_path = join(output_folder, os.path.basename(file_path))
|
||||
with open(new_path, "w") as f:
|
||||
with open(new_path, 'w') as f:
|
||||
f.write(template)
|
||||
|
||||
for file in ready_templates:
|
||||
@@ -259,17 +262,21 @@ def generate_templates(
|
||||
hex_color = rgb_to_hex(rgba)
|
||||
rgb_color = rgba_to_rgb(rgba)
|
||||
new_line = ready_templates[file].format(
|
||||
name=color, hex=hex_color, rgb=rgb_color
|
||||
name=color,
|
||||
hex=hex_color,
|
||||
rgb=rgb_color
|
||||
)
|
||||
_template += new_line
|
||||
if color in additional:
|
||||
new_line = ready_templates[file].format(
|
||||
name=additional[color], hex=hex_color, rgb=rgb_color
|
||||
name=additional[color],
|
||||
hex=hex_color,
|
||||
rgb=rgb_color
|
||||
)
|
||||
_template += new_line
|
||||
|
||||
new_path = join(output_folder, os.path.basename(file))
|
||||
with open(new_path, "w") as f:
|
||||
with open(new_path, 'w') as f:
|
||||
f.write(_template)
|
||||
|
||||
|
||||
@@ -280,9 +287,9 @@ def run_hooks(folder: str):
|
||||
for file_path in file_list:
|
||||
file_name = os.path.basename(file_path)
|
||||
if str(file_name).endswith(".py"):
|
||||
subprocess.run(["python", "-O", file_path])
|
||||
subprocess.run(['python', '-O', file_path])
|
||||
elif str(file_name).endswith(".sh"):
|
||||
subprocess.run(["sh", file_path])
|
||||
subprocess.run(['sh', file_path])
|
||||
|
||||
|
||||
def process_image(image_path, quality=2, num_colors=128):
|
||||
@@ -290,18 +297,18 @@ def process_image(image_path, quality=2, num_colors=128):
|
||||
global cache_path
|
||||
_cache_path = join(cache_path, "cached_colors")
|
||||
hash_object = hashlib.md5(image_path.encode())
|
||||
cache_filename = hash_object.hexdigest() + ".pkl"
|
||||
cache_filename = hash_object.hexdigest() + '.pkl'
|
||||
os.makedirs(_cache_path, exist_ok=True)
|
||||
return join(_cache_path, cache_filename)
|
||||
|
||||
def load_from_cache(cache_path):
|
||||
if os.path.exists(cache_path):
|
||||
with open(cache_path, "rb") as f:
|
||||
with open(cache_path, 'rb') as f:
|
||||
return pickle.load(f)
|
||||
return None
|
||||
|
||||
def save_to_cache(cache_path, data):
|
||||
with open(cache_path, "wb") as f:
|
||||
with open(cache_path, 'wb') as f:
|
||||
pickle.dump(data, f)
|
||||
|
||||
cache_path = get_cache_path(image_path)
|
||||
@@ -310,7 +317,7 @@ def process_image(image_path, quality=2, num_colors=128):
|
||||
if cached_result is not None:
|
||||
return cached_result
|
||||
|
||||
image = Image.open(image_path).convert("RGB")
|
||||
image = Image.open(image_path).convert('RGB')
|
||||
|
||||
image_data = np.array(image)
|
||||
pixel_array = image_data[::quality, ::quality].reshape(-1, 3)
|
||||
@@ -325,11 +332,8 @@ def process_image(image_path, quality=2, num_colors=128):
|
||||
|
||||
|
||||
def main(
|
||||
color_scheme: str,
|
||||
image_path: str,
|
||||
use_color: int | None = None,
|
||||
scheme_name: str | None = None,
|
||||
contrast_level: int = 0,
|
||||
color_scheme: str, image_path: str, use_color: int | None = None,
|
||||
scheme_name: str | None = None, contrast_level: int = 0
|
||||
):
|
||||
scheme_name = scheme_name or "tonalSpot"
|
||||
scheme = schemes[scheme_name]
|
||||
@@ -340,31 +344,34 @@ def main(
|
||||
else:
|
||||
color = use_color
|
||||
|
||||
scheme = scheme(Hct.from_int(color), is_dark, contrast_level)
|
||||
scheme = scheme(
|
||||
Hct.from_int(color),
|
||||
is_dark,
|
||||
contrast_level
|
||||
)
|
||||
# for color in vars(MaterialDynamicColors).keys():
|
||||
# color_name = getattr(MaterialDynamicColors, color)
|
||||
# if hasattr(color_name, "get_hct"):
|
||||
# print(color, rgb_to_hex(color_name.get_hct(scheme).to_rgba()))
|
||||
|
||||
with open(join(cache_path, "colors.json"), "w") as f:
|
||||
object = ColorsCache(scheme, image_path, color, contrast_level, scheme_name)
|
||||
with open(join(cache_path, "colors.json"), 'w') as f:
|
||||
object = ColorsCache(
|
||||
scheme, image_path, color, contrast_level, scheme_name
|
||||
)
|
||||
json.dump(colors_dict(object), f, indent=2)
|
||||
|
||||
generate_templates(
|
||||
f"{script_dir}/templates", cache_path, scheme, color_scheme, image_path
|
||||
)
|
||||
generate_templates(
|
||||
f"{script_dir}/templates/svg",
|
||||
join(cache_path, "svg/"),
|
||||
scheme,
|
||||
color_scheme,
|
||||
image_path,
|
||||
f"{script_dir}/templates/svg", join(cache_path, "svg/"), scheme,
|
||||
color_scheme, image_path
|
||||
)
|
||||
|
||||
if is_dark:
|
||||
subprocess.run(["sh", join(script_dir, "gtk-material.sh")])
|
||||
subprocess.run(['sh', join(script_dir, 'gtk-material.sh')])
|
||||
else:
|
||||
subprocess.run(["sh", join(script_dir, "gtk-material.sh"), "--light"])
|
||||
subprocess.run(['sh', join(script_dir, 'gtk-material.sh'), '--light'])
|
||||
|
||||
run_hooks(join(script_dir, "hooks"))
|
||||
|
||||
@@ -372,27 +379,26 @@ def main(
|
||||
def _argparse() -> tuple[bool, bool, str, str, str, str]:
|
||||
parser = argparse.ArgumentParser()
|
||||
group = parser.add_mutually_exclusive_group(required=True)
|
||||
group.add_argument("-R", help="Restore previous colorscheme.", action="store_true")
|
||||
group.add_argument(
|
||||
"-w", help="Use last used wallpaper for color generation.", action="store_true"
|
||||
"-R", help="Restore previous colorscheme.", action='store_true'
|
||||
)
|
||||
group.add_argument(
|
||||
"-w", help="Use last used wallpaper for color generation.",
|
||||
action='store_true'
|
||||
)
|
||||
group.add_argument(
|
||||
"--image", type=str, help="Image for color scheme generation"
|
||||
)
|
||||
group.add_argument("--image", type=str, help="Image for color scheme generation")
|
||||
group.add_argument(
|
||||
"--color", type=str, help="Main color for color scheme generation"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--color-scheme",
|
||||
type=str,
|
||||
default="dark",
|
||||
choices=["dark", "light"],
|
||||
help="Color scheme variant",
|
||||
'--color-scheme', type=str, default='dark', choices=['dark', 'light'],
|
||||
help="Color scheme variant"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--scheme",
|
||||
type=str,
|
||||
default="",
|
||||
choices=list(schemes.keys()),
|
||||
help="Scheme for color generation",
|
||||
'--scheme', type=str, default="",
|
||||
choices=list(schemes.keys()), help="Scheme for color generation"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
@@ -404,23 +410,15 @@ def _argparse() -> tuple[bool, bool, str, str, str, str]:
|
||||
use_color = args.color
|
||||
scheme = args.scheme
|
||||
return (
|
||||
restore_palette,
|
||||
use_last_used_wallpaper,
|
||||
image,
|
||||
color_scheme,
|
||||
use_color,
|
||||
scheme,
|
||||
restore_palette, use_last_used_wallpaper, image,
|
||||
color_scheme, use_color, scheme
|
||||
)
|
||||
|
||||
|
||||
def _main():
|
||||
(
|
||||
restore_palette,
|
||||
use_last_used_wallpaper,
|
||||
image,
|
||||
color_scheme,
|
||||
use_color,
|
||||
scheme,
|
||||
restore_palette, use_last_used_wallpaper, image,
|
||||
color_scheme, use_color, scheme
|
||||
) = _argparse()
|
||||
if not scheme:
|
||||
scheme = None
|
||||
@@ -429,17 +427,13 @@ def _main():
|
||||
with open(join(cache_path, "colors.json")) as f:
|
||||
content = get_cache_object(f.read())
|
||||
main(
|
||||
color_scheme,
|
||||
image_path=content.wallpaper,
|
||||
use_color=int(use_color.lstrip("#"), 16),
|
||||
scheme_name=scheme,
|
||||
color_scheme, image_path=content.wallpaper,
|
||||
use_color=int(use_color.lstrip('#'), 16), scheme_name=scheme
|
||||
)
|
||||
except Exception:
|
||||
main(
|
||||
color_scheme,
|
||||
image_path="/dev/null",
|
||||
use_color=int(use_color.lstrip("#"), 16),
|
||||
scheme_name=scheme,
|
||||
color_scheme, image_path="/dev/null",
|
||||
use_color=int(use_color.lstrip('#'), 16), scheme_name=scheme
|
||||
)
|
||||
|
||||
elif restore_palette:
|
||||
@@ -450,7 +444,7 @@ def _main():
|
||||
image_path=content.wallpaper,
|
||||
use_color=content.original_color,
|
||||
scheme_name=scheme or content.scheme_name,
|
||||
contrast_level=content.contrast_level,
|
||||
contrast_level=content.contrast_level
|
||||
)
|
||||
elif use_last_used_wallpaper:
|
||||
with open(join(cache_path, "colors.json")) as f:
|
||||
@@ -459,12 +453,13 @@ def _main():
|
||||
color_scheme,
|
||||
image_path=content.wallpaper,
|
||||
scheme_name=scheme or content.scheme_name,
|
||||
contrast_level=content.contrast_level,
|
||||
contrast_level=content.contrast_level
|
||||
)
|
||||
else:
|
||||
if os.path.isdir(image):
|
||||
files = [
|
||||
f for f in os.listdir(image) if f.endswith((".png", ".jpg", ".jpeg"))
|
||||
f for f in os.listdir(image)
|
||||
if f.endswith(('.png', '.jpg', '.jpeg'))
|
||||
]
|
||||
if files:
|
||||
image = join(image, random.choice(files))
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
[colors.primary]
|
||||
background = '<background>'
|
||||
foreground = '<onBackground>'
|
||||
|
||||
|
||||
[colors.cursor]
|
||||
text = '#1E1E2E'
|
||||
cursor = '#F5E0DC'
|
||||
|
||||
[colors.vi_mode_cursor]
|
||||
text = '#1E1E2E'
|
||||
cursor = '#B4BEFE'
|
||||
|
||||
|
||||
[colors.search.matches]
|
||||
foreground = '#1E1E2E'
|
||||
background = '#A6ADC8'
|
||||
|
||||
[colors.search.focused_match]
|
||||
foreground = '#1E1E2E'
|
||||
background = '#A6E3A1'
|
||||
|
||||
[colors.footer_bar]
|
||||
foreground = '#1E1E2E'
|
||||
background = '#A6ADC8'
|
||||
|
||||
|
||||
[colors.hints.start]
|
||||
foreground = '#1E1E2E'
|
||||
background = '#F9E2AF'
|
||||
|
||||
[colors.hints.end]
|
||||
foreground = '#1E1E2E'
|
||||
background = '#A6ADC8'
|
||||
|
||||
|
||||
[colors.selection]
|
||||
text = '#1E1E2E'
|
||||
background = '#F5E0DC'
|
||||
|
||||
|
||||
[colors.normal]
|
||||
black = '#45475A'
|
||||
red = '#F38BA8'
|
||||
green = '#A6E3A1'
|
||||
yellow = '#F9E2AF'
|
||||
blue = '#89B4FA'
|
||||
magenta = '#F5C2E7'
|
||||
cyan = '#94E2D5'
|
||||
white = '#BAC2DE'
|
||||
|
||||
|
||||
[colors.bright]
|
||||
black = '#585B70'
|
||||
red = '#F38BA8'
|
||||
green = '#A6E3A1'
|
||||
yellow = '#F9E2AF'
|
||||
blue = '#89B4FA'
|
||||
magenta = '#F5C2E7'
|
||||
cyan = '#94E2D5'
|
||||
white = '#A6ADC8'
|
||||
|
||||
|
||||
[colors.dim]
|
||||
black = '#45475A'
|
||||
red = '#F38BA8'
|
||||
green = '#A6E3A1'
|
||||
yellow = '#F9E2AF'
|
||||
blue = '#89B4FA'
|
||||
magenta = '#F5C2E7'
|
||||
cyan = '#94E2D5'
|
||||
white = '#BAC2DE'
|
||||
@@ -0,0 +1,72 @@
|
||||
[colors.primary]
|
||||
background = '<background>'
|
||||
foreground = '<onBackground>'
|
||||
|
||||
|
||||
[colors.cursor]
|
||||
text = '#EFF1F5'
|
||||
cursor = '#DC8A78'
|
||||
|
||||
[colors.vi_mode_cursor]
|
||||
text = '#EFF1F5'
|
||||
cursor = '#7287FD'
|
||||
|
||||
|
||||
[colors.search.matches]
|
||||
foreground = '#EFF1F5'
|
||||
background = '#6C6F85'
|
||||
|
||||
[colors.search.focused_match]
|
||||
foreground = '#EFF1F5'
|
||||
background = '#40A02B'
|
||||
|
||||
[colors.footer_bar]
|
||||
foreground = '#EFF1F5'
|
||||
background = '#6C6F85'
|
||||
|
||||
|
||||
[colors.hints.start]
|
||||
foreground = '#EFF1F5'
|
||||
background = '#DF8E1D'
|
||||
|
||||
[colors.hints.end]
|
||||
foreground = '#EFF1F5'
|
||||
background = '#6C6F85'
|
||||
|
||||
|
||||
[colors.selection]
|
||||
text = '#EFF1F5'
|
||||
background = '#DC8A78'
|
||||
|
||||
|
||||
[colors.normal]
|
||||
black = '#5C5F77'
|
||||
red = '#D20F39'
|
||||
green = '#40A02B'
|
||||
yellow = '#DF8E1D'
|
||||
blue = '#1E66F5'
|
||||
magenta = '#EA76CB'
|
||||
cyan = '#179299'
|
||||
white = '#ACB0BE'
|
||||
|
||||
|
||||
[colors.bright]
|
||||
black = '#6C6F85'
|
||||
red = '#D20F39'
|
||||
green = '#40A02B'
|
||||
yellow = '#DF8E1D'
|
||||
blue = '#1E66F5'
|
||||
magenta = '#EA76CB'
|
||||
cyan = '#179299'
|
||||
white = '#BCC0CC'
|
||||
|
||||
|
||||
[colors.dim]
|
||||
black = '#5C5F77'
|
||||
red = '#D20F39'
|
||||
green = '#40A02B'
|
||||
yellow = '#DF8E1D'
|
||||
blue = '#1E66F5'
|
||||
magenta = '#EA76CB'
|
||||
cyan = '#179299'
|
||||
white = '#ACB0BE'
|
||||
@@ -0,0 +1,10 @@
|
||||
[general]
|
||||
import = [
|
||||
"<output-folder>/alacritty-<color-scheme>.toml"
|
||||
]
|
||||
[font]
|
||||
normal = { family = "MesloLGS NF", style = "Regular" }
|
||||
bold = { family = "MesloLGS NF", style = "Bold" }
|
||||
italic = { family = "MesloLGS NF", style = "Italic" }
|
||||
bold_italic = { family = "MesloLGS NF", style = "Bold Italic" }
|
||||
size = 12.0
|
||||
@@ -11,46 +11,45 @@ $saturation: round(color.channel($primary, "saturation", $space: hsl));
|
||||
$lightness: round(color.channel($primary, "lightness", $space: hsl));
|
||||
|
||||
* {
|
||||
transition: color 0.2s ease-in-out;
|
||||
transition-property: background-color, color;
|
||||
transition: color 0.2s ease-in-out;
|
||||
transition-property: background-color, color;
|
||||
}
|
||||
|
||||
.theme-#{$color-scheme} {
|
||||
--main-color: #{$background};
|
||||
--main-alt: #{$surfaceContainerLow};
|
||||
--main-color: #{$background};
|
||||
--main-alt: #{$surfaceContainerLow};
|
||||
|
||||
--message-color: #{$surfaceContainerLowest};
|
||||
--message-color-hover: #{$surfaceContainer};
|
||||
--message-color-alt: #{$surfaceContainer};
|
||||
--attachment-color: #{$background};
|
||||
--message-color: #{$surfaceContainerLowest};
|
||||
--message-color-hover: #{$surfaceContainer};
|
||||
--message-color-alt: #{$surfaceContainer};
|
||||
--attachment-color: #{$background};
|
||||
|
||||
--accent-hue: #{$hue};
|
||||
--accent-saturation: #{$saturation};
|
||||
--accent-lightness: #{$lightness};
|
||||
--accent-text-color: #{$onPrimary};
|
||||
--accent-hue: #{$hue};
|
||||
--accent-saturation: #{$saturation};
|
||||
--accent-lightness: #{$lightness};
|
||||
--accent-text-color: #{$onPrimary};
|
||||
|
||||
--main-textarea-color: #{$surfaceContainerHigh};
|
||||
--main-textarea-color-alt: #{$surfaceContainerHighest};
|
||||
--status-picker-color: #{$surfaceContainerHigh};
|
||||
--main-textarea-color: #{$surfaceContainerHigh};
|
||||
--main-textarea-color-alt: #{$surfaceContainerHighest};
|
||||
--status-picker-color: #{$surfaceContainerHigh};
|
||||
|
||||
--tooltip-color: #{$surfaceContainer};
|
||||
--popout-color: #{$surfaceContainer};
|
||||
--popout-color-alt: #{$surfaceContainerLowest};
|
||||
--popout-header-border: #{$onSurface};
|
||||
--separator-color: #{$outlineVariant};
|
||||
--sidebar-panel-color: #{$surfaceContainerLowest};
|
||||
--server-color: #{$surfaceContainerLow};
|
||||
--tooltip-color: #{$surfaceContainer};
|
||||
--popout-color: #{$surfaceContainer};
|
||||
--popout-color-alt: #{$surfaceContainerLowest};
|
||||
--popout-header-border: #{$onSurface};
|
||||
--separator-color: #{$outlineVariant};
|
||||
--sidebar-panel-color: #{$surfaceContainerLowest};
|
||||
--server-color: #{$surfaceContainerLow};
|
||||
}
|
||||
|
||||
[class*="botTag_"] svg path {
|
||||
fill: #{$onPrimary};
|
||||
fill: #{$onPrimary};
|
||||
}
|
||||
|
||||
[class*="repliedTextContent_"] {
|
||||
padding: 0px 5px 0px 5px !important;
|
||||
padding: 0px 5px 0px 5px !important;
|
||||
}
|
||||
|
||||
[class*="userPopoutOuter_"] {
|
||||
border-radius: 16px !important;
|
||||
border-radius: 16px !important;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user