config: add transparency option

Also remove options for removed features
This commit is contained in:
2 * r + 2 * t 2025-03-23 15:21:11 +11:00
parent 0230997d76
commit acae35aa52
2 changed files with 22 additions and 22 deletions

22
app.tsx
View file

@ -5,20 +5,33 @@ import Osds from "@/modules/osds";
import Popdowns from "@/modules/popdowns";
import Session from "@/modules/session";
import Monitors from "@/services/monitors";
import Palette from "@/services/palette";
import Palette, { type Hex } from "@/services/palette";
import Players from "@/services/players";
import Schemes from "@/services/schemes";
import Wallpapers from "@/services/wallpapers";
import type PopupWindow from "@/widgets/popupwindow";
import { execAsync, idle, timeout, writeFileAsync } from "astal";
import { App } from "astal/gtk3";
import { initConfig, updateConfig } from "config";
import { initConfig, style, updateConfig } from "config";
const shouldBeTransparent = (name: string) =>
name === "base" ||
name === "mantle" ||
name === "crust" ||
name.startsWith("surface") ||
name.startsWith("overlay");
const applyTransparency = (name: string, hex: Hex) => {
if (style.transparency.get() === "off" || !shouldBeTransparent(name)) return hex;
const amount = style.transparency.get() === "high" ? 0.58 : 0.78;
return `color.change(${hex}, $alpha: ${amount})`;
};
export const loadStyleAsync = async () => {
const schemeColours = Object.entries(Palette.get_default().colours)
.map(([name, hex]) => `$${name}: ${hex};`)
.map(([name, hex]) => `$${name}: ${applyTransparency(name, hex)};`)
.join("\n");
await writeFileAsync(`${SRC}/scss/scheme/_index.scss`, schemeColours);
await writeFileAsync(`${SRC}/scss/scheme/_index.scss`, `@use "sass:color";\n${schemeColours}`);
App.apply_css(await execAsync(`sass ${SRC}/style.scss`), true);
};
@ -29,6 +42,7 @@ App.start({
const now = Date.now();
loadStyleAsync().catch(console.error);
style.transparency.subscribe(() => loadStyleAsync().catch(console.error));
Palette.get_default().connect("notify::colours", () => loadStyleAsync().catch(console.error));
initConfig();

View file

@ -46,6 +46,9 @@ export const initConfig = () => {
};
const DEFAULTS = {
style: {
transparency: "normal", // One of "off", "normal", "high"
},
// Modules
bar: {
vertical: true,
@ -92,13 +95,6 @@ const DEFAULTS = {
actionPrefix: ">", // Prefix for launcher actions
apps: {
maxResults: 30, // Actual max results, -1 for infinite
pins: [
["zen", "firefox", "waterfox", "google-chrome", "chromium", "brave-browser"],
["foot", "alacritty", "kitty", "wezterm"],
["thunar", "nemo", "nautilus"],
["codium", "code", "clion", "intellij-idea-ultimate-edition"],
["spotify-adblock", "spotify", "audacious", "elisa"],
],
},
files: {
maxResults: 40, // Actual max results, -1 for infinite
@ -108,16 +104,6 @@ const DEFAULTS = {
math: {
maxResults: 40, // Actual max results, -1 for infinite
},
windows: {
maxResults: -1, // Actual max results, -1 for infinite
weights: {
// Weights for fuzzy sort
title: 1,
class: 1,
initialTitle: 0.5,
initialClass: 0.5,
},
},
todo: {
notify: true,
},
@ -158,7 +144,6 @@ const DEFAULTS = {
directories: {
left: {
top: "󰉍 Downloads",
middle: "󱧶 Documents",
bottom: "󱍙 Music",
},
@ -207,6 +192,7 @@ const DEFAULTS = {
const config = convertSettings(DEFAULTS);
export const {
style,
bar,
launcher,
notifpopups,