From bd93aae83f17f2c5bb6c914b04a9585ab57377e4 Mon Sep 17 00:00:00 2001 From: casglistro Date: Thu, 18 Apr 2024 02:20:38 +0800 Subject: [PATCH 01/16] update dock --- .config/ags/config.js | 3 +- .config/ags/modules/dock/dock.js | 185 ++++++++++++++++++++---------- .config/ags/modules/dock/icons.js | 60 ++++++++++ .config/ags/modules/dock/main.js | 9 +- 4 files changed, 192 insertions(+), 65 deletions(-) create mode 100644 .config/ags/modules/dock/icons.js diff --git a/.config/ags/config.js b/.config/ags/config.js index d024560e..b061a455 100644 --- a/.config/ags/config.js +++ b/.config/ags/config.js @@ -11,7 +11,7 @@ import { firstRunWelcome } from './services/messages.js'; import { Bar, BarCornerTopleft, BarCornerTopright } from './modules/bar/main.js'; import Cheatsheet from './modules/cheatsheet/main.js'; // import DesktopBackground from './modules/desktopbackground/main.js'; -// import Dock from './modules/dock/main.js'; +import Dock from './modules/dock/main.js'; import Corner from './modules/screencorners/main.js'; import Indicator from './modules/indicators/main.js'; import Osk from './modules/onscreenkeyboard/main.js'; @@ -50,6 +50,7 @@ const Windows = () => [ Overview(), forMonitors(Indicator), forMonitors(Cheatsheet), + forMonitors(Dock), SideLeft(), SideRight(), forMonitors(Osk), diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index d35fe757..5b800e2e 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -2,19 +2,26 @@ const { Gtk } = imports.gi; import { SCREEN_HEIGHT, SCREEN_WIDTH } from '../../variables.js'; import Widget from 'resource:///com/github/Aylur/ags/widget.js'; import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'; -const { EventBox } = Widget; +const { EventBox, Button } = Widget; import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js'; import Applications from 'resource:///com/github/Aylur/ags/service/applications.js'; const { execAsync, exec } = Utils; const { Box, Revealer } = Widget; import { setupCursorHover } from '../.widgetutils/cursorhover.js'; +import { getAllFiles, searchIcons } from './icons.js' +import { MaterialIcon } from '../.commonwidgets/materialicon.js'; + +const icon_files = getAllFiles("/usr/share/icons/Tela-nord-dark/scalable/apps") const pinnedApps = [ 'firefox', 'org.gnome.Nautilus', ]; +let isPinned = false +let cachePath = new Map() + function substitute(str) { const subs = [ { from: 'code-url-handler', to: 'visual-studio-code' }, @@ -34,13 +41,50 @@ function substitute(str) { return str; } +function ExclusiveWindow(client) { + const fn = [ + (client) => !(client !== null && client !== undefined), + // Jetbrains + (client) => client.title.includes("win"), + // Vscode + (client) => client.title === '' && client.class === '' + ] + + for (const item of fn) { if (item(client)) { return true } } + return false +} + const focus = ({ address }) => Utils.execAsync(`hyprctl dispatch focuswindow address:${address}`).catch(print); +const activeMonitorId = () => { + let monitors = JSON.parse(exec('hyprctl monitors -j')) + let activeMonitor = monitors.find((e) => e["focused"] === true) + return activeMonitor["id"] +} + const DockSeparator = (props = {}) => Box({ ...props, className: 'dock-separator', }) +const PinButton = () => Widget.Button({ + className: 'dock-app-btn', + tooltipText: 'Pin Dock', + child: Widget.Overlay({ + child: Widget.Box({ + homogeneous: true, + className: 'dock-app-icon', + child: MaterialIcon('Lock', 'larger') + }), + overlays: [Widget.Box({ + class_name: 'indicator', + vpack: 'end', + hpack: 'center', + })], + }), + onClicked: () => isPinned = !isPinned +}) + const AppButton = ({ icon, ...rest }) => Widget.Revealer({ attribute: { 'workspace': 0 @@ -73,14 +117,15 @@ const AppButton = ({ icon, ...rest }) => Widget.Revealer({ }) }); -const Taskbar = () => Widget.Box({ +const Taskbar = (monitor) => Widget.Box({ className: 'dock-apps', attribute: { + monitor: monitor, 'map': new Map(), 'clientSortFunc': (a, b) => { return a.attribute.workspace > b.attribute.workspace; }, - 'update': (box) => { + 'update': (box, monitor) => { for (let i = 0; i < Hyprland.clients.length; i++) { const client = Hyprland.clients[i]; if (client["pid"] == -1) return; @@ -89,8 +134,15 @@ const Taskbar = () => Widget.Box({ if (appClass.includes(appName.toLowerCase())) return null; } + let appClassLower = appClass.toLowerCase() + let path = '' + if (cachePath[appClassLower]) { path = cachePath[appClassLower] } + else { + path = searchIcons(appClass.toLowerCase(), icon_files) + cachePath[appClassLower] = path + } const newButton = AppButton({ - icon: appClass, + icon: path, tooltipText: `${client.title} (${appClass})`, onClicked: () => focus(client), }); @@ -100,7 +152,7 @@ const Taskbar = () => Widget.Box({ } box.children = Array.from(box.attribute.map.values()); }, - 'add': (box, address) => { + 'add': (box, address, monitor) => { if (!address) { // First active emit is undefined box.attribute.update(box); return; @@ -108,10 +160,17 @@ const Taskbar = () => Widget.Box({ const newClient = Hyprland.clients.find(client => { return client.address == address; }); - const appClass = substitute(newClient.class); - + if (ExclusiveWindow(newClient)) { return } + let appClass = newClient.class + let appClassLower = appClass.toLowerCase() + let path = '' + if (cachePath[appClassLower]) { path = cachePath[appClassLower] } + else { + path = searchIcons(appClassLower, icon_files) + cachePath[appClassLower] = path + } const newButton = AppButton({ - icon: appClass, + icon: path, tooltipText: `${newClient.title} (${appClass})`, onClicked: () => focus(newClient), }) @@ -135,8 +194,8 @@ const Taskbar = () => Widget.Box({ }, }, setup: (self) => { - self.hook(Hyprland, (box, address) => box.attribute.add(box, address), 'client-added') - .hook(Hyprland, (box, address) => box.attribute.remove(box, address), 'client-removed') + self.hook(Hyprland, (box, address) => box.attribute.add(box, address, self.monitor), 'client-added') + .hook(Hyprland, (box, address) => box.attribute.remove(box, address, self.monitor), 'client-removed') Utils.timeout(100, () => self.attribute.update(self)); }, }); @@ -149,6 +208,7 @@ const PinnedApps = () => Widget.Box({ .filter(({ app }) => app) .map(({ app, term = true }) => { const newButton = AppButton({ + // different icon, emm... icon: app.icon_name, onClicked: () => { for (const client of Hyprland.clients) { @@ -177,82 +237,87 @@ const PinnedApps = () => Widget.Box({ }), }); -export default () => { +export default (monitor = 0) => { const dockContent = Box({ className: 'dock-bg spacing-h-5', children: [ PinnedApps(), DockSeparator(), - Taskbar(), + Taskbar(monitor), + PinButton(), ] }) const dockRevealer = Revealer({ attribute: { 'updateShow': self => { // I only use mouse to resize. I don't care about keyboard resize if that's a thing - const dockSize = [ - dockContent.get_allocated_width(), - dockContent.get_allocated_height() - ] - const dockAt = [ - SCREEN_WIDTH / 2 - dockSize[0] / 2, - SCREEN_HEIGHT - dockSize[1], - ]; - const dockLeft = dockAt[0]; - const dockRight = dockAt[0] + dockSize[0]; - const dockTop = dockAt[1]; - const dockBottom = dockAt[1] + dockSize[1]; - - const currentWorkspace = Hyprland.active.workspace.id; - var toReveal = true; - const hyprlandClients = JSON.parse(exec('hyprctl clients -j')); - for (const index in hyprlandClients) { - const client = hyprlandClients[index]; - const clientLeft = client.at[0]; - const clientRight = client.at[0] + client.size[0]; - const clientTop = client.at[1]; - const clientBottom = client.at[1] + client.size[1]; - - if (client.workspace.id == currentWorkspace) { - if ( - clientLeft < dockRight && - clientRight > dockLeft && - clientTop < dockBottom && - clientBottom > dockTop - ) { - self.revealChild = false; - return; - } - } - } - self.revealChild = true; + // const dockSize = [ + // dockContent.get_allocated_width(), + // dockContent.get_allocated_height() + // ] + // const dockAt = [ + // SCREEN_WIDTH / 2 - dockSize[0] / 2, + // SCREEN_HEIGHT - dockSize[1], + // ]; + // const dockLeft = dockAt[0]; + // const dockRight = dockAt[0] + dockSize[0]; + // const dockTop = dockAt[1]; + // const dockBottom = dockAt[1] + dockSize[1]; + // + // const currentWorkspace = Hyprland.active.workspace.id; + // var toReveal = true; + // const hyprlandClients = JSON.parse(exec('hyprctl clients -j')); + // for (const index in hyprlandClients) { + // const client = hyprlandClients[index]; + // const clientLeft = client.at[0]; + // const clientRight = client.at[0] + client.size[0]; + // const clientTop = client.at[1]; + // const clientBottom = client.at[1] + client.size[1]; + // + // if (client.workspace.id == currentWorkspace) { + // if ( + // // clientLeft < dockRight && + // // clientRight > dockLeft && + // // clientTop < dockBottom && + // // clientBottom > dockTop + // ) { + // self.revealChild = false; + // return; + // } + // } + // } + // // if (currentWorkspace === client.workspace.id) { + // self.revealChild = true; + // // } + self.revealChild = activeMonitorId() === monitor } }, revealChild: false, transition: 'slide_up', transitionDuration: userOptions.animations.durationLarge, child: dockContent, - // setup: (self) => self - // .hook(Hyprland, (self) => self.attribute.updateShow(self)) - // .hook(Hyprland.active.workspace, (self) => self.attribute.updateShow(self)) - // .hook(Hyprland.active.client, (self) => self.attribute.updateShow(self)) - // .hook(Hyprland, (self) => self.attribute.updateShow(self), 'client-added') - // .hook(Hyprland, (self) => self.attribute.updateShow(self), 'client-removed') - // , + setup: (self) => self + .hook(Hyprland, (self) => self.attribute.updateShow(self)) + .hook(Hyprland.active.workspace, (self) => self.attribute.updateShow(self)) + .hook(Hyprland.active.client, (self) => self.attribute.updateShow(self)) + .hook(Hyprland, (self) => self.attribute.updateShow(self), 'client-added') + .hook(Hyprland, (self) => self.attribute.updateShow(self), 'client-removed') + , }) return EventBox({ onHover: () => { dockRevealer.revealChild = true; }, - onHoverLost: () => { - if (Hyprland.active.client.attribute.class.length === 0) return; - dockRevealer.revealChild = false; - }, + // onHoverLost: () => { + // if (Hyprland.active.client.attribute.class.length === 0) { return } + // dockRevealer.revealChild = false; + // }, child: Box({ homogeneous: true, - css: 'min-height: 2px;', + css: 'min-height: 20px;', children: [ dockRevealer, ] }), + setup: self => self.on("leave-notify-event", () => { if (!isPinned) dockRevealer.revealChild = false }) }) } diff --git a/.config/ags/modules/dock/icons.js b/.config/ags/modules/dock/icons.js new file mode 100644 index 00000000..d9a91c15 --- /dev/null +++ b/.config/ags/modules/dock/icons.js @@ -0,0 +1,60 @@ +const { Gio, GLib } = imports.gi +import { lookUpIcon, timeout } from 'resource:///com/github/Aylur/ags/utils.js'; +import Applications from 'resource:///com/github/Aylur/ags/service/applications.js'; + +const exists = (path) => Gio.File.new_for_path(path).query_exists(null); + +export const levenshteinDistance = (a, b) => { + if (!a.length) { return b.length } + if (!b.length) { return a.length } + + let f = Array.from(new Array(a.length + 1), + () => new Array(b.length + 1).fill(0)) + + for (let i = 0; i <= b.length; i++) { f[0][i] = i; } + for (let i = 0; i <= a.length; i++) { f[i][0] = i; } + + for (let i = 1; i <= a.length; i++) { + for (let j = 1; j <= b.length; j++) { + if (a.charAt(i - 1) === b.charAt(j - 1)) { + f[i][j] = f[i-1][j-1] + } else { + f[i][j] = Math.min(f[i-1][j-1], Math.min(f[i][j-1], f[i-1][j])) + 1 + } + } + } + + return f[a.length][b.length] +} + +export const getAllFiles = (dir, files = []) => { + const file = Gio.File.new_for_path(dir); + const enumerator = file.enumerate_children('standard::name,standard::type', + Gio.FileQueryInfoFlags.NONE, null); + + for (const info of enumerator) { + if (info.get_file_type() === Gio.FileType.DIRECTORY) { + files.push(getAllFiles(`${dir}/${info.get_name()}`)) + } else { + files.push(`${dir}/${info.get_name()}`) + } + } + + return files.flat(1); +} + +export const searchIcons = (appClass, files) => { + let appro = 0x3f3f3f3f + let path = "" + + for (const item of files) { + let score = levenshteinDistance(item.split("/").pop(), appClass) + + if (score < appro) { + appro = score + path = item + } + } + + return path +} \ No newline at end of file diff --git a/.config/ags/modules/dock/main.js b/.config/ags/modules/dock/main.js index cc7bb0e4..38bbbf7b 100644 --- a/.config/ags/modules/dock/main.js +++ b/.config/ags/modules/dock/main.js @@ -1,11 +1,12 @@ import Widget from 'resource:///com/github/Aylur/ags/widget.js'; import Dock from './dock.js'; -export default () => Widget.Window({ - name: 'dock', - layer: 'bottom', +export default (monitor = 0) => Widget.Window({ + monitor, + name: `dock${monitor}`, + layer: 'top', anchor: ['bottom'], exclusivity: 'normal', visible: true, - child: Dock(), + child: Dock(monitor), }); From 844c85e9a2e320f35dbd5a13e2b53943bbcc53e4 Mon Sep 17 00:00:00 2001 From: casglistro Date: Thu, 18 Apr 2024 02:38:03 +0800 Subject: [PATCH 02/16] disable active client signal --- .config/ags/modules/dock/dock.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index 5b800e2e..65c73300 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -296,9 +296,9 @@ export default (monitor = 0) => { transitionDuration: userOptions.animations.durationLarge, child: dockContent, setup: (self) => self - .hook(Hyprland, (self) => self.attribute.updateShow(self)) + // .hook(Hyprland, (self) => self.attribute.updateShow(self)) .hook(Hyprland.active.workspace, (self) => self.attribute.updateShow(self)) - .hook(Hyprland.active.client, (self) => self.attribute.updateShow(self)) + // .hook(Hyprland.active.client, (self) => self.attribute.updateShow(self)) .hook(Hyprland, (self) => self.attribute.updateShow(self), 'client-added') .hook(Hyprland, (self) => self.attribute.updateShow(self), 'client-removed') , From 81fc788e911b841aa70260ed2a2ef125dc2607a9 Mon Sep 17 00:00:00 2001 From: casglistro Date: Thu, 18 Apr 2024 03:07:20 +0800 Subject: [PATCH 03/16] remove useless param --- .config/ags/modules/dock/dock.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index 65c73300..08254966 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -117,15 +117,14 @@ const AppButton = ({ icon, ...rest }) => Widget.Revealer({ }) }); -const Taskbar = (monitor) => Widget.Box({ +const Taskbar = () => Widget.Box({ className: 'dock-apps', attribute: { - monitor: monitor, 'map': new Map(), 'clientSortFunc': (a, b) => { return a.attribute.workspace > b.attribute.workspace; }, - 'update': (box, monitor) => { + 'update': (box) => { for (let i = 0; i < Hyprland.clients.length; i++) { const client = Hyprland.clients[i]; if (client["pid"] == -1) return; @@ -152,7 +151,7 @@ const Taskbar = (monitor) => Widget.Box({ } box.children = Array.from(box.attribute.map.values()); }, - 'add': (box, address, monitor) => { + 'add': (box, address) => { if (!address) { // First active emit is undefined box.attribute.update(box); return; @@ -194,7 +193,7 @@ const Taskbar = (monitor) => Widget.Box({ }, }, setup: (self) => { - self.hook(Hyprland, (box, address) => box.attribute.add(box, address, self.monitor), 'client-added') + self.hook(Hyprland, (box, address) => box.attribute.add(box, address), 'client-added') .hook(Hyprland, (box, address) => box.attribute.remove(box, address, self.monitor), 'client-removed') Utils.timeout(100, () => self.attribute.update(self)); }, @@ -243,7 +242,7 @@ export default (monitor = 0) => { children: [ PinnedApps(), DockSeparator(), - Taskbar(monitor), + Taskbar(), PinButton(), ] }) From 5fcaf1df888470a24baf97ccf76f08f2a7eaf3c9 Mon Sep 17 00:00:00 2001 From: casglistro Date: Thu, 18 Apr 2024 16:38:28 +0800 Subject: [PATCH 04/16] add some configs --- .config/ags/config.js | 5 +- .../modules/.configuration/user_options.js | 37 +++++- .config/ags/modules/dock/dock.js | 124 ++++++++++++------ .config/ags/modules/dock/icons.js | 3 + .config/ags/modules/dock/main.js | 2 +- 5 files changed, 129 insertions(+), 42 deletions(-) diff --git a/.config/ags/config.js b/.config/ags/config.js index b061a455..646f54db 100644 --- a/.config/ags/config.js +++ b/.config/ags/config.js @@ -50,11 +50,11 @@ const Windows = () => [ Overview(), forMonitors(Indicator), forMonitors(Cheatsheet), - forMonitors(Dock), SideLeft(), SideRight(), forMonitors(Osk), Session(), + ...(userOptions.dock.enabled ? [forMonitors(Dock)] : []), // forMonitors(Bar), ...(userOptions.appearance.fakeScreenRounding ? [ forMonitors((id) => Corner(id, 'top left', true)), @@ -82,5 +82,4 @@ App.config({ // Stuff that don't need to be toggled. And they're async so ugh... forMonitorsAsync(Bar); -// Bar().catch(print); // Use this to debug the bar. Single monitor only. - +// Bar().catch(print); // Use this to debug the bar. Single monitor only. \ No newline at end of file diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index 72f285a1..fec81444 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -71,11 +71,46 @@ let configOptions = { 'dateFormat': "%d/%m", // On notif time }, 'weather': { - 'city': "", + 'city': "Chengdu", }, 'workspaces': { 'shown': 10, }, + 'dock': { + 'enabled': false, + // Threshold for hover to trigger dock display + 'hoverMinHeight': 5, + 'pinnedApps': ['firefox', 'org.gnome.Nautilus'], + // top or bottom + 'layer': 'top', + // Find the window's icon by its class with levenshteinDistance + // All file paths are preprocessed and stored at ags startup, so if there + // are so many files under the path it will affect performance + // Maybe you need a comprehensive icon theme + // Example: ['/usr/share/icons/Tela-nord-dark/scalable/apps', 'others...'] + 'iconSearchPaths': [''], + // Dock will move to other monitor along with focus if enabled + 'monitorExclusivity': true, + // It's useful to keep the icons consistent, which is useful if you're OCD :) + 'searchPinnedAppIcons': false, + // available: client_added, client_move, workspace_active, client_active + 'trigger': ['client-added', 'client-removed', + 'workspace-active'], + // Automatically hide dock after a period of time + // after a trigger has been triggered. + // Time in milliseconds. empty if always displays. + // { 'trigger': 'client-added', interval: 1000, } + 'autoHidden': [ + { + 'trigger': 'client-added', + 'interval': 2000, + }, + { + 'trigger': 'client-removed', + 'interval': 2000, + }, + ], + }, // Longer stuff 'icons': { substitutions: { diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index 08254966..8c18c753 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -1,4 +1,4 @@ -const { Gtk } = imports.gi; +const { Gtk, GLib } = imports.gi; import { SCREEN_HEIGHT, SCREEN_WIDTH } from '../../variables.js'; import Widget from 'resource:///com/github/Aylur/ags/widget.js'; import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'; @@ -12,7 +12,7 @@ import { setupCursorHover } from '../.widgetutils/cursorhover.js'; import { getAllFiles, searchIcons } from './icons.js' import { MaterialIcon } from '../.commonwidgets/materialicon.js'; -const icon_files = getAllFiles("/usr/share/icons/Tela-nord-dark/scalable/apps") +const icon_files = userOptions.dock.iconSearchPaths.map(e => getAllFiles(e)).flat(1) const pinnedApps = [ 'firefox', @@ -22,6 +22,13 @@ const pinnedApps = [ let isPinned = false let cachePath = new Map() +let timers = [] + +function clearTimes() { + timers.forEach(e => GLib.source_remove(e)) + timers = [] +} + function substitute(str) { const subs = [ { from: 'code-url-handler', to: 'visual-studio-code' }, @@ -67,23 +74,33 @@ const DockSeparator = (props = {}) => Box({ className: 'dock-separator', }) -const PinButton = () => Widget.Button({ - className: 'dock-app-btn', - tooltipText: 'Pin Dock', - child: Widget.Overlay({ - child: Widget.Box({ - homogeneous: true, - className: 'dock-app-icon', - child: MaterialIcon('Lock', 'larger') +const PinButton = () => { + let botton = Widget.Button({ + className: 'dock-app-btn dock-app-btn-animate', + tooltipText: 'Pin Dock', + child: Widget.Overlay({ + child: Widget.Box({ + homogeneous: true, + className: 'dock-app-icon', + child: MaterialIcon('Lock', 'larger') + }), + overlays: [Widget.Box({ + class_name: 'indicator', + vpack: 'end', + hpack: 'center', + })], }), - overlays: [Widget.Box({ - class_name: 'indicator', - vpack: 'end', - hpack: 'center', - })], - }), - onClicked: () => isPinned = !isPinned -}) + onClicked: () => { + isPinned = !isPinned + botton.className = `${isPinned ? "pinned-dock-app-btn" : "dock-app-btn animate"} dock-app-btn-animate` + }, + setup: (button) => { + setupCursorHover(button); + } + }) + + return botton +} const AppButton = ({ icon, ...rest }) => Widget.Revealer({ attribute: { @@ -94,7 +111,7 @@ const AppButton = ({ icon, ...rest }) => Widget.Revealer({ transitionDuration: userOptions.animations.durationLarge, child: Widget.Button({ ...rest, - className: 'dock-app-btn', + className: 'dock-app-btn dock-app-btn-animate', child: Widget.Box({ child: Widget.Overlay({ child: Widget.Box({ @@ -117,14 +134,15 @@ const AppButton = ({ icon, ...rest }) => Widget.Revealer({ }) }); -const Taskbar = () => Widget.Box({ +const Taskbar = (monitor) => Widget.Box({ className: 'dock-apps', attribute: { + monitor: monitor, 'map': new Map(), 'clientSortFunc': (a, b) => { return a.attribute.workspace > b.attribute.workspace; }, - 'update': (box) => { + 'update': (box, monitor) => { for (let i = 0; i < Hyprland.clients.length; i++) { const client = Hyprland.clients[i]; if (client["pid"] == -1) return; @@ -151,7 +169,7 @@ const Taskbar = () => Widget.Box({ } box.children = Array.from(box.attribute.map.values()); }, - 'add': (box, address) => { + 'add': (box, address, monitor) => { if (!address) { // First active emit is undefined box.attribute.update(box); return; @@ -193,7 +211,7 @@ const Taskbar = () => Widget.Box({ }, }, setup: (self) => { - self.hook(Hyprland, (box, address) => box.attribute.add(box, address), 'client-added') + self.hook(Hyprland, (box, address) => box.attribute.add(box, address, self.monitor), 'client-added') .hook(Hyprland, (box, address) => box.attribute.remove(box, address, self.monitor), 'client-removed') Utils.timeout(100, () => self.attribute.update(self)); }, @@ -208,7 +226,9 @@ const PinnedApps = () => Widget.Box({ .map(({ app, term = true }) => { const newButton = AppButton({ // different icon, emm... - icon: app.icon_name, + icon: userOptions.dock.searchPinnedAppIcons ? + searchIcons(app.icon_name, icon_files) : + app.icon_name, onClicked: () => { for (const client of Hyprland.clients) { if (client.class.toLowerCase().includes(term)) @@ -287,36 +307,66 @@ export default (monitor = 0) => { // // if (currentWorkspace === client.workspace.id) { // self.revealChild = true; // // } - self.revealChild = activeMonitorId() === monitor + + if (userOptions.dock.monitorExclusivity) { + self.revealChild = activeMonitorId() === monitor + } else { + self.revealChild = true; + } + + return self.revealChild } }, revealChild: false, transition: 'slide_up', transitionDuration: userOptions.animations.durationLarge, child: dockContent, - setup: (self) => self - // .hook(Hyprland, (self) => self.attribute.updateShow(self)) - .hook(Hyprland.active.workspace, (self) => self.attribute.updateShow(self)) - // .hook(Hyprland.active.client, (self) => self.attribute.updateShow(self)) - .hook(Hyprland, (self) => self.attribute.updateShow(self), 'client-added') - .hook(Hyprland, (self) => self.attribute.updateShow(self), 'client-removed') + setup: (self) => { + const callback = (self, trigger) => { + if (!userOptions.dock.trigger.includes(trigger)) return + const flag = self.attribute.updateShow(self) + + if (flag) { clearTimes() } + + const hidden = userOptions + .dock + .autoHidden.find(e => e["trigger"] === trigger) + + if (hidden) { + let id = Utils.timeout(hidden.interval, () => { + if (!isPinned) { self.revealChild = false } + timers = timers.filter(e => e !== id) + }) + timers.push(id) + } + } + + self + // .hook(Hyprland, (self) => self.attribute.updateShow(self)) + .hook(Hyprland.active.workspace, self => callback(self, "workspace-active")) + .hook(Hyprland.active.client, self => callback(self, "client-active")) + .hook(Hyprland, self => callback(self, "client-added"), "client-added") + .hook(Hyprland, self => callback(self, "client-removed"), "client-removed") + } , }) return EventBox({ onHover: () => { dockRevealer.revealChild = true; + clearTimes() }, - // onHoverLost: () => { - // if (Hyprland.active.client.attribute.class.length === 0) { return } - // dockRevealer.revealChild = false; - // }, child: Box({ homogeneous: true, - css: 'min-height: 20px;', + css: `min-height: ${userOptions.dock.hoverMinHeight}px;`, children: [ dockRevealer, ] }), - setup: self => self.on("leave-notify-event", () => { if (!isPinned) dockRevealer.revealChild = false }) + setup: self => self.on("leave-notify-event", () => { + if (!isPinned) dockRevealer.revealChild = false; + clearTimes() + }).on('key-press-event', (self, event) => { + console.log(self, event) + }) }) } diff --git a/.config/ags/modules/dock/icons.js b/.config/ags/modules/dock/icons.js index d9a91c15..a16e8ff0 100644 --- a/.config/ags/modules/dock/icons.js +++ b/.config/ags/modules/dock/icons.js @@ -28,6 +28,7 @@ export const levenshteinDistance = (a, b) => { } export const getAllFiles = (dir, files = []) => { + if (!exists(dir)) { return [] } const file = Gio.File.new_for_path(dir); const enumerator = file.enumerate_children('standard::name,standard::type', Gio.FileQueryInfoFlags.NONE, null); @@ -44,6 +45,8 @@ export const getAllFiles = (dir, files = []) => { } export const searchIcons = (appClass, files) => { + if (!files.length) { return "" } + let appro = 0x3f3f3f3f let path = "" diff --git a/.config/ags/modules/dock/main.js b/.config/ags/modules/dock/main.js index 38bbbf7b..77d394d9 100644 --- a/.config/ags/modules/dock/main.js +++ b/.config/ags/modules/dock/main.js @@ -4,7 +4,7 @@ import Dock from './dock.js'; export default (monitor = 0) => Widget.Window({ monitor, name: `dock${monitor}`, - layer: 'top', + layer: userOptions.dock.layer, anchor: ['bottom'], exclusivity: 'normal', visible: true, From d7ab69211aa55eeb8718786b30e92aa49da360d3 Mon Sep 17 00:00:00 2001 From: casglistro Date: Thu, 18 Apr 2024 16:44:04 +0800 Subject: [PATCH 05/16] use origin appClass when failed to search icons --- .config/ags/modules/dock/dock.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index 8c18c753..a6c2fc6c 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -158,6 +158,7 @@ const Taskbar = (monitor) => Widget.Box({ path = searchIcons(appClass.toLowerCase(), icon_files) cachePath[appClassLower] = path } + if (path === '') { path = appClass } const newButton = AppButton({ icon: path, tooltipText: `${client.title} (${appClass})`, @@ -186,6 +187,7 @@ const Taskbar = (monitor) => Widget.Box({ path = searchIcons(appClassLower, icon_files) cachePath[appClassLower] = path } + if (path === '') { path = substitute(appClassLower) } const newButton = AppButton({ icon: path, tooltipText: `${newClient.title} (${appClass})`, From 2e60a44e702f9453c05f80da0c8cb00301de301c Mon Sep 17 00:00:00 2001 From: casglistro Date: Thu, 18 Apr 2024 16:46:08 +0800 Subject: [PATCH 06/16] use substitute --- .config/ags/modules/dock/dock.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index a6c2fc6c..150d7e5e 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -158,7 +158,7 @@ const Taskbar = (monitor) => Widget.Box({ path = searchIcons(appClass.toLowerCase(), icon_files) cachePath[appClassLower] = path } - if (path === '') { path = appClass } + if (path === '') { path = substitute(appClass) } const newButton = AppButton({ icon: path, tooltipText: `${client.title} (${appClass})`, @@ -187,7 +187,7 @@ const Taskbar = (monitor) => Widget.Box({ path = searchIcons(appClassLower, icon_files) cachePath[appClassLower] = path } - if (path === '') { path = substitute(appClassLower) } + if (path === '') { path = substitute(appClass) } const newButton = AppButton({ icon: path, tooltipText: `${newClient.title} (${appClass})`, From 5365846ba4fb72e4f452a311a9a875fed2e5ff23 Mon Sep 17 00:00:00 2001 From: casglistro Date: Thu, 18 Apr 2024 17:39:44 +0800 Subject: [PATCH 07/16] move config into new category --- .config/ags/modules/dock/dock.js | 21 +++++++-------------- .config/ags/modules/dock/icons.js | 6 +++--- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index 150d7e5e..06a5cef9 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -12,12 +12,7 @@ import { setupCursorHover } from '../.widgetutils/cursorhover.js'; import { getAllFiles, searchIcons } from './icons.js' import { MaterialIcon } from '../.commonwidgets/materialicon.js'; -const icon_files = userOptions.dock.iconSearchPaths.map(e => getAllFiles(e)).flat(1) - -const pinnedApps = [ - 'firefox', - 'org.gnome.Nautilus', -]; +const icon_files = userOptions.icon.searchPaths.map(e => getAllFiles(e)).flat(1) let isPinned = false let cachePath = new Map() @@ -147,10 +142,10 @@ const Taskbar = (monitor) => Widget.Box({ const client = Hyprland.clients[i]; if (client["pid"] == -1) return; const appClass = substitute(client.class); - for (const appName of pinnedApps) { - if (appClass.includes(appName.toLowerCase())) - return null; - } + // for (const appName of userOptions.dock.pinnedApps) { + // if (appClass.includes(appName.toLowerCase())) + // return null; + // } let appClassLower = appClass.toLowerCase() let path = '' if (cachePath[appClassLower]) { path = cachePath[appClassLower] } @@ -222,14 +217,14 @@ const Taskbar = (monitor) => Widget.Box({ const PinnedApps = () => Widget.Box({ class_name: 'dock-apps', homogeneous: true, - children: pinnedApps + children: userOptions.dock.pinnedApps .map(term => ({ app: Applications.query(term)?.[0], term })) .filter(({ app }) => app) .map(({ app, term = true }) => { const newButton = AppButton({ // different icon, emm... icon: userOptions.dock.searchPinnedAppIcons ? - searchIcons(app.icon_name, icon_files) : + searchIcons(app.name, icon_files) : app.icon_name, onClicked: () => { for (const client of Hyprland.clients) { @@ -367,8 +362,6 @@ export default (monitor = 0) => { setup: self => self.on("leave-notify-event", () => { if (!isPinned) dockRevealer.revealChild = false; clearTimes() - }).on('key-press-event', (self, event) => { - console.log(self, event) }) }) } diff --git a/.config/ags/modules/dock/icons.js b/.config/ags/modules/dock/icons.js index a16e8ff0..60f01a3a 100644 --- a/.config/ags/modules/dock/icons.js +++ b/.config/ags/modules/dock/icons.js @@ -1,6 +1,4 @@ const { Gio, GLib } = imports.gi -import { lookUpIcon, timeout } from 'resource:///com/github/Aylur/ags/utils.js'; -import Applications from 'resource:///com/github/Aylur/ags/service/applications.js'; const exists = (path) => Gio.File.new_for_path(path).query_exists(null); @@ -45,13 +43,15 @@ export const getAllFiles = (dir, files = []) => { } export const searchIcons = (appClass, files) => { + appClass = appClass.toLowerCase() + if (!files.length) { return "" } let appro = 0x3f3f3f3f let path = "" for (const item of files) { - let score = levenshteinDistance(item.split("/").pop(), appClass) + let score = levenshteinDistance(item.split("/").pop().toLowerCase().split(".")[0], appClass) if (score < appro) { appro = score From ac2fb2e6a6aba3425a44296758d8da6aa72915b7 Mon Sep 17 00:00:00 2001 From: casglistro Date: Thu, 18 Apr 2024 17:42:18 +0800 Subject: [PATCH 08/16] and description... --- .config/ags/scss/_dock.scss | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.config/ags/scss/_dock.scss b/.config/ags/scss/_dock.scss index 45d3d892..2e087ffe 100644 --- a/.config/ags/scss/_dock.scss +++ b/.config/ags/scss/_dock.scss @@ -5,11 +5,22 @@ padding: 0.682rem; } +.dock-app-btn-animate { + transition-property: background-color; + transition-duration: 0.5s; +} + .dock-app-btn { @include normal-rounding; padding: 0.273rem; } +.pinned-dock-app-btn { + @include normal-rounding; + padding: 0.273rem; + background-color: $layer0Hover; +} + .dock-app-btn:hover, .dock-app-btn:focus { background-color: $layer0Hover; From 73f88863429e25553d8cd59422860c8bcbd98d31 Mon Sep 17 00:00:00 2001 From: casglistro Date: Thu, 18 Apr 2024 18:00:19 +0800 Subject: [PATCH 09/16] update user_options.js --- .config/ags/modules/dock/dock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index 06a5cef9..1326f16e 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -12,7 +12,7 @@ import { setupCursorHover } from '../.widgetutils/cursorhover.js'; import { getAllFiles, searchIcons } from './icons.js' import { MaterialIcon } from '../.commonwidgets/materialicon.js'; -const icon_files = userOptions.icon.searchPaths.map(e => getAllFiles(e)).flat(1) +const icon_files = userOptions.icons.searchPaths.map(e => getAllFiles(e)).flat(1) let isPinned = false let cachePath = new Map() From 17d93cd0f29898f5960e97fe289473e0886d08a3 Mon Sep 17 00:00:00 2001 From: casglistro Date: Thu, 18 Apr 2024 18:06:11 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=F0=9F=A4=94=20update=20user=5Foptions.js?= =?UTF-8?q?=20again?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ags/modules/.configuration/user_options.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index fec81444..5577c5c9 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -71,7 +71,7 @@ let configOptions = { 'dateFormat': "%d/%m", // On notif time }, 'weather': { - 'city': "Chengdu", + 'city': "", }, 'workspaces': { 'shown': 10, @@ -83,12 +83,6 @@ let configOptions = { 'pinnedApps': ['firefox', 'org.gnome.Nautilus'], // top or bottom 'layer': 'top', - // Find the window's icon by its class with levenshteinDistance - // All file paths are preprocessed and stored at ags startup, so if there - // are so many files under the path it will affect performance - // Maybe you need a comprehensive icon theme - // Example: ['/usr/share/icons/Tela-nord-dark/scalable/apps', 'others...'] - 'iconSearchPaths': [''], // Dock will move to other monitor along with focus if enabled 'monitorExclusivity': true, // It's useful to keep the icons consistent, which is useful if you're OCD :) @@ -113,6 +107,13 @@ let configOptions = { }, // Longer stuff 'icons': { + // Find the window's icon by its class with levenshteinDistance + // All file paths are preprocessed and stored at ags startup, so if there + // are so many files under the path it will affect performance + // Maybe you need a comprehensive icon theme + // Example: ['/usr/share/icons/Tela-nord/scalable/apps', 'others...'] + 'searchPaths': [''], + substitutions: { 'code-url-handler': "visual-studio-code", 'Code': "visual-studio-code", From 28731a2316b048d45eb10d75c30e8c018b4ac4a7 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:36:56 +0700 Subject: [PATCH 11/16] adjust config options --- .config/ags/modules/.configuration/user_options.js | 11 ++++------- .config/ags/modules/dock/dock.js | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index 5577c5c9..416a57be 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -77,24 +77,21 @@ let configOptions = { 'shown': 10, }, 'dock': { - 'enabled': false, + 'enabled': true, // Threshold for hover to trigger dock display 'hoverMinHeight': 5, 'pinnedApps': ['firefox', 'org.gnome.Nautilus'], - // top or bottom 'layer': 'top', - // Dock will move to other monitor along with focus if enabled - 'monitorExclusivity': true, + 'monitorExclusivity': true, // Dock will move to other monitor along with focus if enabled // It's useful to keep the icons consistent, which is useful if you're OCD :) 'searchPinnedAppIcons': false, // available: client_added, client_move, workspace_active, client_active - 'trigger': ['client-added', 'client-removed', - 'workspace-active'], + 'trigger': ['client-added', 'client-removed'], // Automatically hide dock after a period of time // after a trigger has been triggered. // Time in milliseconds. empty if always displays. // { 'trigger': 'client-added', interval: 1000, } - 'autoHidden': [ + 'autoHide': [ { 'trigger': 'client-added', 'interval': 2000, diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index 1326f16e..92005c2f 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -327,7 +327,7 @@ export default (monitor = 0) => { const hidden = userOptions .dock - .autoHidden.find(e => e["trigger"] === trigger) + .autoHide.find(e => e["trigger"] === trigger) if (hidden) { let id = Utils.timeout(hidden.interval, () => { From 4b9065277f928be1b58a0f0e8d394667a509d5b5 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:43:15 +0700 Subject: [PATCH 12/16] adjust dock pin icon --- .config/ags/modules/.configuration/user_options.js | 4 ++-- .config/ags/modules/dock/dock.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index 416a57be..099c6dda 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -94,11 +94,11 @@ let configOptions = { 'autoHide': [ { 'trigger': 'client-added', - 'interval': 2000, + 'interval': 1000, }, { 'trigger': 'client-removed', - 'interval': 2000, + 'interval': 1000, }, ], }, diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index 92005c2f..a7cb0ad6 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -77,7 +77,7 @@ const PinButton = () => { child: Widget.Box({ homogeneous: true, className: 'dock-app-icon', - child: MaterialIcon('Lock', 'larger') + child: MaterialIcon('push_pin', 'hugeass') }), overlays: [Widget.Box({ class_name: 'indicator', From 7794fb8bd5a1822c9eab1a46c43c197698ee0b0e Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:49:58 +0700 Subject: [PATCH 13/16] get active monitor id: use hyprland service --- .config/ags/modules/dock/dock.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index a7cb0ad6..f2ae0034 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -58,12 +58,6 @@ function ExclusiveWindow(client) { const focus = ({ address }) => Utils.execAsync(`hyprctl dispatch focuswindow address:${address}`).catch(print); -const activeMonitorId = () => { - let monitors = JSON.parse(exec('hyprctl monitors -j')) - let activeMonitor = monitors.find((e) => e["focused"] === true) - return activeMonitor["id"] -} - const DockSeparator = (props = {}) => Box({ ...props, className: 'dock-separator', @@ -306,7 +300,7 @@ export default (monitor = 0) => { // // } if (userOptions.dock.monitorExclusivity) { - self.revealChild = activeMonitorId() === monitor + self.revealChild = Hyprland.active.monitor.id === monitor } else { self.revealChild = true; } From b9403ebfaf98ad5dde3491490cf640bc1d471924 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:54:04 +0700 Subject: [PATCH 14/16] remove unecessary array spread; rename hidden dock thickness option --- .config/ags/config.js | 2 +- .config/ags/modules/.configuration/user_options.js | 3 +-- .config/ags/modules/dock/dock.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.config/ags/config.js b/.config/ags/config.js index 646f54db..b4523f91 100644 --- a/.config/ags/config.js +++ b/.config/ags/config.js @@ -54,7 +54,7 @@ const Windows = () => [ SideRight(), forMonitors(Osk), Session(), - ...(userOptions.dock.enabled ? [forMonitors(Dock)] : []), + userOptions.dock.enabled ? forMonitors(Dock) : null, // forMonitors(Bar), ...(userOptions.appearance.fakeScreenRounding ? [ forMonitors((id) => Corner(id, 'top left', true)), diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index 099c6dda..826fc2cd 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -78,8 +78,7 @@ let configOptions = { }, 'dock': { 'enabled': true, - // Threshold for hover to trigger dock display - 'hoverMinHeight': 5, + 'hiddenThickness': 5, 'pinnedApps': ['firefox', 'org.gnome.Nautilus'], 'layer': 'top', 'monitorExclusivity': true, // Dock will move to other monitor along with focus if enabled diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index f2ae0034..d30f41e9 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -348,7 +348,7 @@ export default (monitor = 0) => { }, child: Box({ homogeneous: true, - css: `min-height: ${userOptions.dock.hoverMinHeight}px;`, + css: `min-height: ${userOptions.dock.hiddenThickness}px;`, children: [ dockRevealer, ] From 67a2e3c3d7ee6f316ae64a68bacd72ae72958d59 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:59:28 +0700 Subject: [PATCH 15/16] update config option descriptions --- .../ags/modules/.configuration/user_options.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index 826fc2cd..0aec54ec 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -82,14 +82,9 @@ let configOptions = { 'pinnedApps': ['firefox', 'org.gnome.Nautilus'], 'layer': 'top', 'monitorExclusivity': true, // Dock will move to other monitor along with focus if enabled - // It's useful to keep the icons consistent, which is useful if you're OCD :) - 'searchPinnedAppIcons': false, - // available: client_added, client_move, workspace_active, client_active - 'trigger': ['client-added', 'client-removed'], - // Automatically hide dock after a period of time - // after a trigger has been triggered. - // Time in milliseconds. empty if always displays. - // { 'trigger': 'client-added', interval: 1000, } + 'searchPinnedAppIcons': false, // Try to search for the correct icon if the app class isn't an icon name + 'trigger': ['client-added', 'client-removed'], // client_added, client_move, workspace_active, client_active + // Automatically hide dock after `interval` ms since trigger 'autoHide': [ { 'trigger': 'client-added', @@ -104,10 +99,9 @@ let configOptions = { // Longer stuff 'icons': { // Find the window's icon by its class with levenshteinDistance - // All file paths are preprocessed and stored at ags startup, so if there - // are so many files under the path it will affect performance - // Maybe you need a comprehensive icon theme - // Example: ['/usr/share/icons/Tela-nord/scalable/apps', 'others...'] + // The file names are processed at startup, so if there + // are too many files in the search path it'll affect performance + // Example: ['/usr/share/icons/Tela-nord/scalable/apps'] 'searchPaths': [''], substitutions: { From 0c275a0dbb7f856aac0353daf12978643871be1c Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:06:52 +0700 Subject: [PATCH 16/16] format --- .config/ags/modules/dock/dock.js | 66 +++++++++++++------------------- 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/.config/ags/modules/dock/dock.js b/.config/ags/modules/dock/dock.js index d30f41e9..4e6cc326 100644 --- a/.config/ags/modules/dock/dock.js +++ b/.config/ags/modules/dock/dock.js @@ -63,33 +63,27 @@ const DockSeparator = (props = {}) => Box({ className: 'dock-separator', }) -const PinButton = () => { - let botton = Widget.Button({ - className: 'dock-app-btn dock-app-btn-animate', - tooltipText: 'Pin Dock', - child: Widget.Overlay({ - child: Widget.Box({ - homogeneous: true, - className: 'dock-app-icon', - child: MaterialIcon('push_pin', 'hugeass') - }), - overlays: [Widget.Box({ - class_name: 'indicator', - vpack: 'end', - hpack: 'center', - })], +const PinButton = () => Widget.Button({ + className: 'dock-app-btn dock-app-btn-animate', + tooltipText: 'Pin Dock', + child: Widget.Overlay({ + child: Widget.Box({ + homogeneous: true, + className: 'dock-app-icon', + child: MaterialIcon('push_pin', 'hugeass') }), - onClicked: () => { - isPinned = !isPinned - botton.className = `${isPinned ? "pinned-dock-app-btn" : "dock-app-btn animate"} dock-app-btn-animate` - }, - setup: (button) => { - setupCursorHover(button); - } - }) - - return botton -} + overlays: [Widget.Box({ + class_name: 'indicator', + vpack: 'end', + hpack: 'center', + })], + }), + onClicked: (self) => { + isPinned = !isPinned + self.className = `${isPinned ? "pinned-dock-app-btn" : "dock-app-btn animate"} dock-app-btn-animate` + }, + setup: setupCursorHover, +}) const AppButton = ({ icon, ...rest }) => Widget.Revealer({ attribute: { @@ -299,11 +293,10 @@ export default (monitor = 0) => { // self.revealChild = true; // // } - if (userOptions.dock.monitorExclusivity) { - self.revealChild = Hyprland.active.monitor.id === monitor - } else { + if (userOptions.dock.monitorExclusivity) + self.revealChild = Hyprland.active.monitor.id === monitor; + else self.revealChild = true; - } return self.revealChild } @@ -317,11 +310,9 @@ export default (monitor = 0) => { if (!userOptions.dock.trigger.includes(trigger)) return const flag = self.attribute.updateShow(self) - if (flag) { clearTimes() } + if (flag) clearTimes(); - const hidden = userOptions - .dock - .autoHide.find(e => e["trigger"] === trigger) + const hidden = userOptions.dock.autoHide.find(e => e["trigger"] === trigger) if (hidden) { let id = Utils.timeout(hidden.interval, () => { @@ -338,8 +329,7 @@ export default (monitor = 0) => { .hook(Hyprland.active.client, self => callback(self, "client-active")) .hook(Hyprland, self => callback(self, "client-added"), "client-added") .hook(Hyprland, self => callback(self, "client-removed"), "client-removed") - } - , + }, }) return EventBox({ onHover: () => { @@ -349,9 +339,7 @@ export default (monitor = 0) => { child: Box({ homogeneous: true, css: `min-height: ${userOptions.dock.hiddenThickness}px;`, - children: [ - dockRevealer, - ] + children: [dockRevealer], }), setup: self => self.on("leave-notify-event", () => { if (!isPinned) dockRevealer.revealChild = false;