Skip to content

Commit

Permalink
feat(ags): for wezterm, use running cmd icons when available
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 30, 2024
1 parent a12f5ba commit dd8fcea
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
30 changes: 16 additions & 14 deletions config/ags/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,22 @@ export function findApp(klass: string) {

if (ret.length === 0) ret = filter(["name", "executable", "description"])

if (ret.length > 1) print(`multiple apps found for ${klass}`)
ret.forEach((app) => {
const props = [
"name",
"icon_name",
"desktop",
"wm_class",
"description",
"frequency",
"executable",
]
print(` - name: ${app.name}`)
for (const prop of props) print(` * ${prop}: ${app[prop]}`)
})
if (ret.length > 1) {
print(`multiple apps found for ${klass}`)
ret.forEach((app) => {
const props = [
"name",
"icon_name",
"desktop",
"wm_class",
"description",
"frequency",
"executable",
]
print(` - name: ${app.name}`)
for (const prop of props) print(` * ${prop}: ${app[prop]}`)
})
}

if (ret.length === 0) print(`no app found for ${klass}`)
return ret[0]
Expand Down
27 changes: 18 additions & 9 deletions config/ags/widget/bar/buttons/Taskbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,23 @@ const AppItem = (address: string) => {

const title = Utils.watch(client.title, hyprland, () => hyprland.getClient(address)?.title || "")

const icon_name = app?.icon_name ?? client.class
const ico = Utils.merge([title, monochrome.bind()], (title, monochrome) => {
let icon_name = app?.icon_name ?? client.class
let icon_fallback = icons.fallback.executable

if (app?.name === "WezTerm") {
const cmd = title.split(" ")[1]
if (cmd) {
icon_fallback = icon_name
icon_name = cmd
}
}

return icon(
icon_name + (monochrome ? "-symbolic" : ""),
icon_fallback + (monochrome ? "-symbolic" : "")
)
})

const btn = PanelButton({
class_name: "panel-button",
Expand All @@ -34,14 +50,7 @@ const AppItem = (address: string) => {
child: Widget.Box([
Widget.Icon({
size: iconSize.bind(),
icon: monochrome
.bind()
.as((m) =>
icon(
icon_name + (m ? "-symbolic" : ""),
icons.fallback.executable + (m ? "-symbolic" : "")
)
),
icon: ico,
}),
Widget.Label({
label: title,
Expand Down

0 comments on commit dd8fcea

Please sign in to comment.