diff --git a/config/ags/.eslintrc.yml b/config/ags/.eslintrc.yml deleted file mode 100644 index 1dd5a5b0..00000000 --- a/config/ags/.eslintrc.yml +++ /dev/null @@ -1,59 +0,0 @@ -env: - es2022: true -extends: - - eslint:recommended - - plugin:@typescript-eslint/recommended -parser: "@typescript-eslint/parser" -parserOptions: - ecmaVersion: 2022 - sourceType: module - project: ./tsconfig.json - warnOnUnsupportedTypeScriptVersion: false -root: true -ignorePatterns: - - types/ -plugins: - - "@typescript-eslint" -rules: - "@typescript-eslint/ban-ts-comment": - - "off" - "@typescript-eslint/no-non-null-assertion": - - "off" - # "@typescript-eslint/no-explicit-any": - # - "off" - "@typescript-eslint/no-unused-vars": - - error - - varsIgnorePattern: (^unused|_$) - argsIgnorePattern: ^(unused|_) - "@typescript-eslint/no-empty-interface": - - "off" - indent: - - error - - 2 - - SwitchCase: 1 - linebreak-style: - - error - - unix - quotes: - - error - - single - - avoidEscape: true - semi: - - error - - never - no-trailing-spaces: - - error -globals: - pkg: readonly - ags: readonly - ARGV: readonly - imports: readonly - print: readonly - console: readonly - logError: readonly - - App: writable - Utils: writable - Widget: writable - Service: writable - Variable: writable diff --git a/config/ags/modules/bar.ts b/config/ags/modules/bar.ts index 69f4daa4..06d806bc 100644 --- a/config/ags/modules/bar.ts +++ b/config/ags/modules/bar.ts @@ -90,102 +90,48 @@ function getIconNameFromClass(windowClass: string) { const dispatch = (ws: string) => hyprland.messageAsync(`dispatch workspace ${ws}`).catch(print); + function Workspaces() { - return EventBox({ - onScrollUp: () => dispatch("+1"), - onScrollDown: () => dispatch("-1"), - className: "workspaces", - child: Box({ - className: "outer-workspace", - children: Array.from({ length: 9 }, (_, i) => i + 1).map( - (i, index, array) => - Box({ - attribute: i, - className: - index === 0 - ? "workspace first" - : index === array.length - 1 - ? "workspace last" - : "workspace", - }) - ), - }).hook(hyprland, (self) => { - let previousWorkspace = {}; - previousWorkspace.className = ""; - self.children.forEach((box, index, array) => { - const isActive = hyprland.active.workspace.id === box.attribute; - const isOccupied = hyprland.workspaces.some( - (item) => item.id === box.attribute - ); - let buttonClassName; - if (isActive) { - buttonClassName = "focused"; - box.className = "workspace focused"; - } else if (isOccupied) { - buttonClassName = "occupied"; - box.className = "workspace occupied"; - } else { - buttonClassName = "normal"; - box.className = "workspace normal"; - } + const activeId = hyprland.active.workspace.bind("id"); + let workspaceButtons = new Map(); - if (isOccupied || isActive) { - if (index === 0) box.toggleClassName("occupied-start", true); - else if ( - index === 8 && - previousWorkspace.className.indexOf("occupied-start") === -1 - ) - box.toggleClassName("occupied-single", true); - else if ( - index === 8 && - previousWorkspace.className.indexOf("occupied-middle") === -1 - ) - box.toggleClassName("occupied-end", true); - else if ( - previousWorkspace.className.indexOf("occupied-start") !== -1 - ) { - box.toggleClassName("occupied-end", true); - } else if ( - previousWorkspace.className.indexOf("occupied-end") !== -1 - ) { - previousWorkspace.toggleClassName("occupied-middle", true); - previousWorkspace.toggleClassName("occupied-end", false); - box.toggleClassName("occupied-end", true); - } else { - box.toggleClassName("occupied-start", true); - } - } else { - if (previousWorkspace.className.indexOf("occupied-start") !== -1) { - previousWorkspace.toggleClassName("occupied-start", false); - previousWorkspace.toggleClassName("occupied-single", true); - } - } + function createWorkspaceButton(id: Number) { + const button = Widget.Button({ + on_clicked: () => dispatch(`${id}`), + child: Widget.Label(`${id}`), + class_name: activeId.as(i => `${i === id ? "active" : ""}`), + }); + return button; + } - if (index === 0) { - box.toggleClassName("first", true); - } else if (index === array.length - 1) { - box.toggleClassName("last", true); - } + function updateWorkspaceButtons(workspaces: Workspace[]): Array> { + workspaces.sort((a, b) => a.id - b.id); - box.child = Button({ - className: buttonClassName, - label: box.attribute.toString(), - onClicked: () => dispatch(box.attribute), - setup: (self) => { - if (index === 0) { - self.toggleClassName("first", true); - } else if (index === array.length - 1) { - self.toggleClassName("last", true); - } - }, - }); + const updatedButtons = new Map(); - // Pass current workspace attributes as previousWorkspace - previousWorkspace = box; - }); - }), - }); + workspaces.forEach(({ id }) => { + if (workspaceButtons.has(id)) { + updatedButtons.set(id, workspaceButtons.get(id)); + } else { + updatedButtons.set(id, createWorkspaceButton(id)); + } + }); + if (workspaceButtons != updatedButtons) + workspaceButtons = updatedButtons; + return Array.from(workspaceButtons.values()); + } + + const workspaceButtonsArray = hyprland.bind("workspaces").as(updateWorkspaceButtons); + + return Widget.EventBox({ + onScrollUp: () => dispatch('+1'), + onScrollDown: () => dispatch('-1'), + child: Widget.Box({ + children: workspaceButtonsArray, + class_name: "workspaces", + }), + }); } diff --git a/config/ags/style.css b/config/ags/style.css index b226394d..f4fb57eb 100644 --- a/config/ags/style.css +++ b/config/ags/style.css @@ -85,81 +85,43 @@ separator { * Workspaces * ----------------------------------------------------- */ -.outer-workspace { - background-color: @surfaceContainer; - border-radius: 20px; - margin: 2px; - padding: 2px 0px; +.workspaces { + border-radius: 16px; + font-weight: bold; + font-style: normal; + font-size: 16px; + color: @onSurface; + background: @surfaceContainer; } -.workspace { - background-color: @onSecondary; - padding: 0; +.workspaces * { + transition: all 0.35s ease-in-out; + transition-property: background-color, color, min-width; } -.workspace button { - padding: 0px 6px; +.workspaces button { + padding: 0px 5px; + margin: 4px 3px; + border-radius: 16px; + border: 0px; } -.workspace.first { - border-radius: 20px 0 0 20px; -} -.workspace.last { - border-radius: 0 20px 20px 0; +.workspaces button label { + color: @onSurface; + font-weight: bold; } -.workspace.normal, -.workspace button.normal { - background-color: transparent; - +.workspaces button:hover { + color: @onSurface; + background: @surfaceContainerHighest; } -.workspace button.normal:hover { - border-radius: 20px; - background-color: @onSecondaryContainer; - color: @primary; +.workspaces button.active { + color: @onSecondaryContainer; + background: @secondaryContainer; + min-width: 40px; } -.workspace button.focused { - background-color: @secondary; - color: @surface; - font-weight: bold; - border-radius: 20px; -} - -.workspace button.focused:hover { - border-radius: 20px; - color: @primary; - background-color: @secondaryContainer; -} - -.workspace button.occupied { - color: @primary;; -} - -.workspaces button.occupied:hover { - border-radius: 20px; - background-color: @secondaryContainer;; - color: @primary; -} - -.workspace.occupied-single { - border-radius: 20px; -} - -.workspace.occupied-start { - border-radius: 20px 0 0 20px; -} - -.workspace.occupied-middle { - border-radius: 0px; -} - -.workspace.occupied-end { - border-radius: 0px 20px 20px 0px; -} - - /* ----------------------------------------------------- * Clock * ----------------------------------------------------- */ @@ -401,7 +363,6 @@ window.notification-popups box.notifications { font-weight: normal; } - /* ----------------------------------------------------- * Media player * ----------------------------------------------------- */ @@ -515,7 +476,6 @@ window.notification-popups box.notifications { font-family: "Font Awesome 6 Free"; } - .battery { background-color: @surfaceContainer; border-radius: 100px; @@ -681,7 +641,7 @@ window.notification-popups box.notifications { } .system_scale.backlight { - margin-bottom: 28px; + margin-bottom: 25px; } .system_scale.brightness slider { @@ -816,7 +776,7 @@ window.notification-popups box.notifications { color: @onSecondaryContainer; border-radius: 100px; min-width: 35px; - padding-right: 6px; + padding: 0px; } .filled_tonal_button label, .filled_tonal_button .icon, @@ -1120,7 +1080,6 @@ switch:checked:hover slider, switch:checked:active slider { padding: 4px; } - /* ----------------------------------------------------- * Material * ----------------------------------------------------- */