diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-02 23:38:04 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-02 23:38:04 +1100 |
| commit | 65d05114085ccd6717c8c4805da85a5e2d80ecf3 (patch) | |
| tree | 282fb6fdb3cca799512b30218fa3b8c45ed4981c | |
| parent | launcher: fix typeerror (diff) | |
| download | caelestia-shell-65d05114085ccd6717c8c4805da85a5e2d80ecf3.tar.gz caelestia-shell-65d05114085ccd6717c8c4805da85a5e2d80ecf3.tar.bz2 caelestia-shell-65d05114085ccd6717c8c4805da85a5e2d80ecf3.zip | |
bar: fix workspaces visual glitch
Also use gtk truncate for active window and media playing
For some reason, odd numbers of workspaces need the adjustment, but even don't
| -rw-r--r-- | scss/bar.scss | 4 | ||||
| -rw-r--r-- | src/modules/bar.tsx | 18 | ||||
| -rw-r--r-- | src/utils/strings.ts | 2 |
3 files changed, 12 insertions, 12 deletions
diff --git a/scss/bar.scss b/scss/bar.scss index ca292fa..b23bb5e 100644 --- a/scss/bar.scss +++ b/scss/bar.scss @@ -276,7 +276,7 @@ border-bottom-left-radius: lib.s($-rounding); } - .workspaces { + .workspaces.odd { margin-right: -1px; } @@ -300,7 +300,7 @@ padding-top: lib.s(15); } - .workspaces { + .workspaces.odd { margin-bottom: -1px; } diff --git a/src/modules/bar.tsx b/src/modules/bar.tsx index c5a4fbb..731e3e7 100644 --- a/src/modules/bar.tsx +++ b/src/modules/bar.tsx @@ -3,7 +3,6 @@ import type { Monitor } from "@/services/monitors"; import Players from "@/services/players"; import Updates from "@/services/updates"; import { getAppCategoryIcon } from "@/utils/icons"; -import { ellipsize } from "@/utils/strings"; import { bindCurrentTime, osIcon } from "@/utils/system"; import type { AstalWidget } from "@/utils/types"; import { setupCustomTooltip } from "@/utils/widgets"; @@ -146,12 +145,11 @@ const ActiveWindow = ({ monitor, ...props }: ModuleProps) => ( } /> <label + truncate angle={bind(config.vertical).as(v => (v ? 270 : 0))} setup={self => { const update = () => - (self.label = hyprland.focusedClient?.title - ? ellipsize(hyprland.focusedClient.title, config.vertical.get() ? 25 : 40) - : "Desktop"); + (self.label = hyprland.focusedClient?.title ? hyprland.focusedClient.title : "Desktop"); hookFocusedClientProp(self, "title", update); self.hook(config.vertical, update); }} @@ -192,11 +190,10 @@ const MediaPlaying = ({ monitor, ...props }: ModuleProps) => { } /> <label + truncate angle={bind(config.vertical).as(v => (v ? 270 : 0))} setup={self => { - // TODO: scroll text when playing or hover - const update = () => - (self.label = ellipsize(getLabel("No media"), config.vertical.get() ? 25 : 40)); + const update = () => (self.label = getLabel("No media")); players.hookLastPlayer(self, ["notify::title", "notify::artist"], update); self.hook(config.vertical, update); }} @@ -255,7 +252,12 @@ const Workspaces = ({ monitor, ...props }: ModuleProps) => ( hyprland.dispatch("workspace", (event.delta_y < 0 ? "-" : "+") + 1); }} > - <box vertical={bind(config.vertical)} className={`module workspaces ${getClassName(props)}`}> + <box + vertical={bind(config.vertical)} + className={bind(config.modules.workspaces.shown).as( + s => `module workspaces ${s % 2 === 0 ? "even" : "odd"} ${getClassName(props)}` + )} + > {bind(config.modules.workspaces.shown).as( n => Array.from({ length: n }).map((_, idx) => <Workspace idx={idx + 1} />) // Start from 1 )} diff --git a/src/utils/strings.ts b/src/utils/strings.ts index 4aaa916..4786c6b 100644 --- a/src/utils/strings.ts +++ b/src/utils/strings.ts @@ -1,5 +1,3 @@ -export const ellipsize = (str: string, len: number) => (str.length > len ? `${str.slice(0, len - 1)}…` : str); - export const basename = (path: string, stripExt = true) => { const lastSlash = path.lastIndexOf("/"); const lastDot = path.lastIndexOf("."); |