move config into new category

This commit is contained in:
casglistro
2024-04-18 17:39:44 +08:00
parent 2e60a44e70
commit 5365846ba4
2 changed files with 10 additions and 17 deletions
+7 -14
View File
@@ -12,12 +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 = userOptions.dock.iconSearchPaths.map(e => getAllFiles(e)).flat(1) const icon_files = userOptions.icon.searchPaths.map(e => getAllFiles(e)).flat(1)
const pinnedApps = [
'firefox',
'org.gnome.Nautilus',
];
let isPinned = false let isPinned = false
let cachePath = new Map() let cachePath = new Map()
@@ -147,10 +142,10 @@ const Taskbar = (monitor) => Widget.Box({
const client = Hyprland.clients[i]; const client = Hyprland.clients[i];
if (client["pid"] == -1) return; if (client["pid"] == -1) return;
const appClass = substitute(client.class); const appClass = substitute(client.class);
for (const appName of pinnedApps) { // for (const appName of userOptions.dock.pinnedApps) {
if (appClass.includes(appName.toLowerCase())) // if (appClass.includes(appName.toLowerCase()))
return null; // return null;
} // }
let appClassLower = appClass.toLowerCase() let appClassLower = appClass.toLowerCase()
let path = '' let path = ''
if (cachePath[appClassLower]) { path = cachePath[appClassLower] } if (cachePath[appClassLower]) { path = cachePath[appClassLower] }
@@ -222,14 +217,14 @@ const Taskbar = (monitor) => Widget.Box({
const PinnedApps = () => Widget.Box({ const PinnedApps = () => Widget.Box({
class_name: 'dock-apps', class_name: 'dock-apps',
homogeneous: true, homogeneous: true,
children: pinnedApps children: userOptions.dock.pinnedApps
.map(term => ({ app: Applications.query(term)?.[0], term })) .map(term => ({ app: Applications.query(term)?.[0], term }))
.filter(({ app }) => app) .filter(({ app }) => app)
.map(({ app, term = true }) => { .map(({ app, term = true }) => {
const newButton = AppButton({ const newButton = AppButton({
// different icon, emm... // different icon, emm...
icon: userOptions.dock.searchPinnedAppIcons ? icon: userOptions.dock.searchPinnedAppIcons ?
searchIcons(app.icon_name, icon_files) : searchIcons(app.name, icon_files) :
app.icon_name, app.icon_name,
onClicked: () => { onClicked: () => {
for (const client of Hyprland.clients) { for (const client of Hyprland.clients) {
@@ -367,8 +362,6 @@ export default (monitor = 0) => {
setup: self => self.on("leave-notify-event", () => { setup: self => self.on("leave-notify-event", () => {
if (!isPinned) dockRevealer.revealChild = false; if (!isPinned) dockRevealer.revealChild = false;
clearTimes() clearTimes()
}).on('key-press-event', (self, event) => {
console.log(self, event)
}) })
}) })
} }
+3 -3
View File
@@ -1,6 +1,4 @@
const { Gio, GLib } = imports.gi 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); 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) => { export const searchIcons = (appClass, files) => {
appClass = appClass.toLowerCase()
if (!files.length) { return "" } if (!files.length) { return "" }
let appro = 0x3f3f3f3f let appro = 0x3f3f3f3f
let path = "" let path = ""
for (const item of files) { 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) { if (score < appro) {
appro = score appro = score