From cf55e2613314e27243c60395e58665b9309280c8 Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Sat, 22 Feb 2025 19:58:07 +1100
Subject: config: use config file
Config file at ~/.config/caelestia/shell.json
---
src/modules/bar.tsx | 152 +++++++++++++++++++++++++++-----------------
src/modules/launcher.tsx | 23 ++++---
src/modules/notifpopups.tsx | 2 +-
src/modules/osds.tsx | 18 +++---
4 files changed, 116 insertions(+), 79 deletions(-)
(limited to 'src/modules')
diff --git a/src/modules/bar.tsx b/src/modules/bar.tsx
index cf3ce5e..c1c3dfc 100644
--- a/src/modules/bar.tsx
+++ b/src/modules/bar.tsx
@@ -8,7 +8,7 @@ import type { AstalWidget } from "@/utils/types";
import { setupCustomTooltip } from "@/utils/widgets";
import type PopupWindow from "@/widgets/popupwindow";
import { execAsync, Variable } from "astal";
-import { bind, kebabify } from "astal/binding";
+import Binding, { bind, kebabify } from "astal/binding";
import { App, Astal, Gtk } from "astal/gtk3";
import { bar as config } from "config";
import AstalBattery from "gi://AstalBattery";
@@ -17,7 +17,7 @@ import AstalHyprland from "gi://AstalHyprland";
import AstalNetwork from "gi://AstalNetwork";
import AstalNotifd from "gi://AstalNotifd";
import AstalTray from "gi://AstalTray";
-import AstalWp01 from "gi://AstalWp";
+import AstalWp from "gi://AstalWp";
const hyprland = AstalHyprland.get_default();
@@ -83,7 +83,7 @@ const OSIcon = () => (
const ActiveWindow = () => (
{
const title = Variable("");
@@ -109,14 +109,15 @@ const ActiveWindow = () => (
}
/>
);
@@ -139,7 +140,7 @@ const MediaPlaying = () => {
setupCustomTooltip(self, bind(label));
}}
>
-
+
players.hookLastPlayer(self, "notify::identity", () => {
@@ -155,12 +156,14 @@ const MediaPlaying = () => {
}
/>
@@ -169,8 +172,8 @@ const MediaPlaying = () => {
const Workspace = ({ idx }: { idx: number }) => {
let wsId = hyprland.focusedWorkspace
- ? Math.floor((hyprland.focusedWorkspace.id - 1) / config.modules.workspaces.shown) *
- config.modules.workspaces.shown +
+ ? Math.floor((hyprland.focusedWorkspace.id - 1) / config.modules.workspaces.shown.get()) *
+ config.modules.workspaces.shown.get() +
idx
: idx;
return (
@@ -184,16 +187,18 @@ const Workspace = ({ idx }: { idx: number }) => {
"occupied",
hyprland.clients.some(c => c.workspace?.id === wsId)
);
-
- self.hook(hyprland, "notify::focused-workspace", () => {
+ const updateWs = () => {
if (!hyprland.focusedWorkspace) return;
wsId =
- Math.floor((hyprland.focusedWorkspace.id - 1) / config.modules.workspaces.shown) *
- config.modules.workspaces.shown +
+ Math.floor((hyprland.focusedWorkspace.id - 1) / config.modules.workspaces.shown.get()) *
+ config.modules.workspaces.shown.get() +
idx;
self.toggleClassName("focused", hyprland.focusedWorkspace.id === wsId);
update();
- });
+ };
+
+ self.hook(config.modules.workspaces.shown, updateWs);
+ self.hook(hyprland, "notify::focused-workspace", () => updateWs);
self.hook(hyprland, "client-added", update);
self.hook(hyprland, "client-moved", update);
self.hook(hyprland, "client-removed", update);
@@ -214,10 +219,10 @@ const Workspaces = () => (
hyprland.dispatch("workspace", (event.delta_y < 0 ? "-" : "+") + 1);
}}
>
-
- {Array.from({ length: config.modules.workspaces.shown }).map((_, idx) => (
- // Start from 1
- ))}
+
+ {bind(config.modules.workspaces.shown).as(
+ n => Array.from({ length: n }).map((_, idx) => ) // Start from 1
+ )}
);
@@ -226,7 +231,7 @@ const TrayItem = (item: AstalTray.TrayItem) => (
event.get_button()[1] === Astal.MouseButton.SECONDARY && item.activate(0, 0)}
usePopover={false}
- direction={config.vertical ? Gtk.ArrowType.RIGHT : Gtk.ArrowType.DOWN}
+ direction={bind(config.vertical).as(v => (v ? Gtk.ArrowType.RIGHT : Gtk.ArrowType.DOWN))}
menuModel={bind(item, "menuModel")}
actionGroup={bind(item, "actionGroup").as(a => ["dbusmenu", a])}
setup={self => setupCustomTooltip(self, bind(item, "tooltipMarkup"))}
@@ -237,7 +242,7 @@ const TrayItem = (item: AstalTray.TrayItem) => (
const Tray = () => (
i.length > 0)}
>
@@ -370,7 +375,7 @@ const BluetoothDevice = (device: AstalBluetooth.Device) => (
);
const Bluetooth = () => (
-
+