forked from Shinonome/dots-hyprland
add some configs
This commit is contained in:
@@ -50,11 +50,11 @@ const Windows = () => [
|
|||||||
Overview(),
|
Overview(),
|
||||||
forMonitors(Indicator),
|
forMonitors(Indicator),
|
||||||
forMonitors(Cheatsheet),
|
forMonitors(Cheatsheet),
|
||||||
forMonitors(Dock),
|
|
||||||
SideLeft(),
|
SideLeft(),
|
||||||
SideRight(),
|
SideRight(),
|
||||||
forMonitors(Osk),
|
forMonitors(Osk),
|
||||||
Session(),
|
Session(),
|
||||||
|
...(userOptions.dock.enabled ? [forMonitors(Dock)] : []),
|
||||||
// forMonitors(Bar),
|
// forMonitors(Bar),
|
||||||
...(userOptions.appearance.fakeScreenRounding ? [
|
...(userOptions.appearance.fakeScreenRounding ? [
|
||||||
forMonitors((id) => Corner(id, 'top left', true)),
|
forMonitors((id) => Corner(id, 'top left', true)),
|
||||||
@@ -83,4 +83,3 @@ App.config({
|
|||||||
// Stuff that don't need to be toggled. And they're async so ugh...
|
// Stuff that don't need to be toggled. And they're async so ugh...
|
||||||
forMonitorsAsync(Bar);
|
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.
|
||||||
|
|
||||||
|
|||||||
@@ -71,11 +71,46 @@ let configOptions = {
|
|||||||
'dateFormat': "%d/%m", // On notif time
|
'dateFormat': "%d/%m", // On notif time
|
||||||
},
|
},
|
||||||
'weather': {
|
'weather': {
|
||||||
'city': "",
|
'city': "Chengdu",
|
||||||
},
|
},
|
||||||
'workspaces': {
|
'workspaces': {
|
||||||
'shown': 10,
|
'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
|
// Longer stuff
|
||||||
'icons': {
|
'icons': {
|
||||||
substitutions: {
|
substitutions: {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const { Gtk } = imports.gi;
|
const { Gtk, GLib } = imports.gi;
|
||||||
import { SCREEN_HEIGHT, SCREEN_WIDTH } from '../../variables.js';
|
import { SCREEN_HEIGHT, SCREEN_WIDTH } from '../../variables.js';
|
||||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.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 { getAllFiles, searchIcons } from './icons.js'
|
||||||
import { MaterialIcon } from '../.commonwidgets/materialicon.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 = [
|
const pinnedApps = [
|
||||||
'firefox',
|
'firefox',
|
||||||
@@ -22,6 +22,13 @@ const pinnedApps = [
|
|||||||
let isPinned = false
|
let isPinned = false
|
||||||
let cachePath = new Map()
|
let cachePath = new Map()
|
||||||
|
|
||||||
|
let timers = []
|
||||||
|
|
||||||
|
function clearTimes() {
|
||||||
|
timers.forEach(e => GLib.source_remove(e))
|
||||||
|
timers = []
|
||||||
|
}
|
||||||
|
|
||||||
function substitute(str) {
|
function substitute(str) {
|
||||||
const subs = [
|
const subs = [
|
||||||
{ from: 'code-url-handler', to: 'visual-studio-code' },
|
{ from: 'code-url-handler', to: 'visual-studio-code' },
|
||||||
@@ -67,23 +74,33 @@ const DockSeparator = (props = {}) => Box({
|
|||||||
className: 'dock-separator',
|
className: 'dock-separator',
|
||||||
})
|
})
|
||||||
|
|
||||||
const PinButton = () => Widget.Button({
|
const PinButton = () => {
|
||||||
className: 'dock-app-btn',
|
let botton = Widget.Button({
|
||||||
tooltipText: 'Pin Dock',
|
className: 'dock-app-btn dock-app-btn-animate',
|
||||||
child: Widget.Overlay({
|
tooltipText: 'Pin Dock',
|
||||||
child: Widget.Box({
|
child: Widget.Overlay({
|
||||||
homogeneous: true,
|
child: Widget.Box({
|
||||||
className: 'dock-app-icon',
|
homogeneous: true,
|
||||||
child: MaterialIcon('Lock', 'larger')
|
className: 'dock-app-icon',
|
||||||
|
child: MaterialIcon('Lock', 'larger')
|
||||||
|
}),
|
||||||
|
overlays: [Widget.Box({
|
||||||
|
class_name: 'indicator',
|
||||||
|
vpack: 'end',
|
||||||
|
hpack: 'center',
|
||||||
|
})],
|
||||||
}),
|
}),
|
||||||
overlays: [Widget.Box({
|
onClicked: () => {
|
||||||
class_name: 'indicator',
|
isPinned = !isPinned
|
||||||
vpack: 'end',
|
botton.className = `${isPinned ? "pinned-dock-app-btn" : "dock-app-btn animate"} dock-app-btn-animate`
|
||||||
hpack: 'center',
|
},
|
||||||
})],
|
setup: (button) => {
|
||||||
}),
|
setupCursorHover(button);
|
||||||
onClicked: () => isPinned = !isPinned
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return botton
|
||||||
|
}
|
||||||
|
|
||||||
const AppButton = ({ icon, ...rest }) => Widget.Revealer({
|
const AppButton = ({ icon, ...rest }) => Widget.Revealer({
|
||||||
attribute: {
|
attribute: {
|
||||||
@@ -94,7 +111,7 @@ const AppButton = ({ icon, ...rest }) => Widget.Revealer({
|
|||||||
transitionDuration: userOptions.animations.durationLarge,
|
transitionDuration: userOptions.animations.durationLarge,
|
||||||
child: Widget.Button({
|
child: Widget.Button({
|
||||||
...rest,
|
...rest,
|
||||||
className: 'dock-app-btn',
|
className: 'dock-app-btn dock-app-btn-animate',
|
||||||
child: Widget.Box({
|
child: Widget.Box({
|
||||||
child: Widget.Overlay({
|
child: Widget.Overlay({
|
||||||
child: Widget.Box({
|
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',
|
className: 'dock-apps',
|
||||||
attribute: {
|
attribute: {
|
||||||
|
monitor: monitor,
|
||||||
'map': new Map(),
|
'map': new Map(),
|
||||||
'clientSortFunc': (a, b) => {
|
'clientSortFunc': (a, b) => {
|
||||||
return a.attribute.workspace > b.attribute.workspace;
|
return a.attribute.workspace > b.attribute.workspace;
|
||||||
},
|
},
|
||||||
'update': (box) => {
|
'update': (box, monitor) => {
|
||||||
for (let i = 0; i < Hyprland.clients.length; i++) {
|
for (let i = 0; i < Hyprland.clients.length; i++) {
|
||||||
const client = Hyprland.clients[i];
|
const client = Hyprland.clients[i];
|
||||||
if (client["pid"] == -1) return;
|
if (client["pid"] == -1) return;
|
||||||
@@ -151,7 +169,7 @@ const Taskbar = () => Widget.Box({
|
|||||||
}
|
}
|
||||||
box.children = Array.from(box.attribute.map.values());
|
box.children = Array.from(box.attribute.map.values());
|
||||||
},
|
},
|
||||||
'add': (box, address) => {
|
'add': (box, address, monitor) => {
|
||||||
if (!address) { // First active emit is undefined
|
if (!address) { // First active emit is undefined
|
||||||
box.attribute.update(box);
|
box.attribute.update(box);
|
||||||
return;
|
return;
|
||||||
@@ -193,7 +211,7 @@ const Taskbar = () => Widget.Box({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup: (self) => {
|
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')
|
.hook(Hyprland, (box, address) => box.attribute.remove(box, address, self.monitor), 'client-removed')
|
||||||
Utils.timeout(100, () => self.attribute.update(self));
|
Utils.timeout(100, () => self.attribute.update(self));
|
||||||
},
|
},
|
||||||
@@ -208,7 +226,9 @@ const PinnedApps = () => Widget.Box({
|
|||||||
.map(({ app, term = true }) => {
|
.map(({ app, term = true }) => {
|
||||||
const newButton = AppButton({
|
const newButton = AppButton({
|
||||||
// different icon, emm...
|
// different icon, emm...
|
||||||
icon: app.icon_name,
|
icon: userOptions.dock.searchPinnedAppIcons ?
|
||||||
|
searchIcons(app.icon_name, icon_files) :
|
||||||
|
app.icon_name,
|
||||||
onClicked: () => {
|
onClicked: () => {
|
||||||
for (const client of Hyprland.clients) {
|
for (const client of Hyprland.clients) {
|
||||||
if (client.class.toLowerCase().includes(term))
|
if (client.class.toLowerCase().includes(term))
|
||||||
@@ -287,36 +307,66 @@ export default (monitor = 0) => {
|
|||||||
// // if (currentWorkspace === client.workspace.id) {
|
// // if (currentWorkspace === client.workspace.id) {
|
||||||
// self.revealChild = true;
|
// self.revealChild = true;
|
||||||
// // }
|
// // }
|
||||||
self.revealChild = activeMonitorId() === monitor
|
|
||||||
|
if (userOptions.dock.monitorExclusivity) {
|
||||||
|
self.revealChild = activeMonitorId() === monitor
|
||||||
|
} else {
|
||||||
|
self.revealChild = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self.revealChild
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
revealChild: false,
|
revealChild: false,
|
||||||
transition: 'slide_up',
|
transition: 'slide_up',
|
||||||
transitionDuration: userOptions.animations.durationLarge,
|
transitionDuration: userOptions.animations.durationLarge,
|
||||||
child: dockContent,
|
child: dockContent,
|
||||||
setup: (self) => self
|
setup: (self) => {
|
||||||
// .hook(Hyprland, (self) => self.attribute.updateShow(self))
|
const callback = (self, trigger) => {
|
||||||
.hook(Hyprland.active.workspace, (self) => self.attribute.updateShow(self))
|
if (!userOptions.dock.trigger.includes(trigger)) return
|
||||||
// .hook(Hyprland.active.client, (self) => self.attribute.updateShow(self))
|
const flag = self.attribute.updateShow(self)
|
||||||
.hook(Hyprland, (self) => self.attribute.updateShow(self), 'client-added')
|
|
||||||
.hook(Hyprland, (self) => self.attribute.updateShow(self), 'client-removed')
|
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({
|
return EventBox({
|
||||||
onHover: () => {
|
onHover: () => {
|
||||||
dockRevealer.revealChild = true;
|
dockRevealer.revealChild = true;
|
||||||
|
clearTimes()
|
||||||
},
|
},
|
||||||
// onHoverLost: () => {
|
|
||||||
// if (Hyprland.active.client.attribute.class.length === 0) { return }
|
|
||||||
// dockRevealer.revealChild = false;
|
|
||||||
// },
|
|
||||||
child: Box({
|
child: Box({
|
||||||
homogeneous: true,
|
homogeneous: true,
|
||||||
css: 'min-height: 20px;',
|
css: `min-height: ${userOptions.dock.hoverMinHeight}px;`,
|
||||||
children: [
|
children: [
|
||||||
dockRevealer,
|
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)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export const levenshteinDistance = (a, b) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getAllFiles = (dir, files = []) => {
|
export const getAllFiles = (dir, files = []) => {
|
||||||
|
if (!exists(dir)) { return [] }
|
||||||
const file = Gio.File.new_for_path(dir);
|
const file = Gio.File.new_for_path(dir);
|
||||||
const enumerator = file.enumerate_children('standard::name,standard::type',
|
const enumerator = file.enumerate_children('standard::name,standard::type',
|
||||||
Gio.FileQueryInfoFlags.NONE, null);
|
Gio.FileQueryInfoFlags.NONE, null);
|
||||||
@@ -44,6 +45,8 @@ export const getAllFiles = (dir, files = []) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const searchIcons = (appClass, files) => {
|
export const searchIcons = (appClass, files) => {
|
||||||
|
if (!files.length) { return "" }
|
||||||
|
|
||||||
let appro = 0x3f3f3f3f
|
let appro = 0x3f3f3f3f
|
||||||
let path = ""
|
let path = ""
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import Dock from './dock.js';
|
|||||||
export default (monitor = 0) => Widget.Window({
|
export default (monitor = 0) => Widget.Window({
|
||||||
monitor,
|
monitor,
|
||||||
name: `dock${monitor}`,
|
name: `dock${monitor}`,
|
||||||
layer: 'top',
|
layer: userOptions.dock.layer,
|
||||||
anchor: ['bottom'],
|
anchor: ['bottom'],
|
||||||
exclusivity: 'normal',
|
exclusivity: 'normal',
|
||||||
visible: true,
|
visible: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user