Merge pull request #117 from ThatOneCalculator/fix/app-icons

app icon fetching adjustments
This commit is contained in:
Lemmy 2025-08-20 20:44:52 -04:00 committed by GitHub
commit a240eb027c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 14 deletions

View file

@ -111,6 +111,7 @@ Singleton {
bar: JsonObject {
property string position: "top" // Possible values: "top", "bottom"
property bool showActiveWindow: true
property bool showActiveWindowIcon: true
property bool showSystemInfo: false
property bool showMedia: false
property bool showBrightness: true

View file

@ -2,6 +2,7 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import Quickshell.Widgets
import qs.Commons
import qs.Services
import qs.Widgets
@ -43,6 +44,15 @@ Row {
return focusedWindow ? (focusedWindow.title || focusedWindow.appId || "") : ""
}
function getAppIcon() {
const focusedWindow = CompositorService.getFocusedWindow();
if (!focusedWindow || !focusedWindow.appId)
return "";
let icon = Quickshell.iconPath(DesktopEntries.byId(focusedWindow.appId).icon);
return icon || "";
}
// A hidden text element to safely measure the full title width
NText {
id: fullTitleMetrics
@ -72,13 +82,20 @@ Row {
spacing: Style.marginXS * scaling
// Window icon
NIcon {
id: windowIcon
text: "dialogs"
font.pointSize: Style.fontSizeL * scaling
verticalAlignment: Text.AlignVCenter
Item {
width: Style.fontSizeL * scaling * 1.2
height: Style.fontSizeL * scaling * 1.2
anchors.verticalCenter: parent.verticalCenter
visible: getTitle() !== ""
visible: getTitle() !== "" && Settings.data.bar.showActiveWindowIcon
IconImage {
id: windowIcon
anchors.fill: parent
source: getAppIcon()
asynchronous: true
smooth: true
visible: source !== ""
}
}
NText {

View file

@ -159,13 +159,7 @@ Loader {
function getAppIcon(toplevel: Toplevel): string {
if (!toplevel)
return ""
let icon = Quickshell.iconPath(toplevel.appId?.toLowerCase(), true)
if (!icon)
icon = Quickshell.iconPath(toplevel.appId, true)
if (!icon)
icon = Quickshell.iconPath(toplevel.title?.toLowerCase(), true)
if (!icon)
icon = Quickshell.iconPath(toplevel.title, true)
let icon = Quickshell.iconPath(DesktopEntries.byId(toplevel.appId?.toLowerCase()).icon);
return icon || Quickshell.iconPath("application-x-executable", true)
}

View file

@ -87,6 +87,15 @@ ColumnLayout {
}
}
NToggle {
label: "Show App Icon Next To Active Window"
description: "Display the app icon next to the title of the currently focused window."
checked: Settings.data.bar.showActiveWindowIcon
onToggled: checked => {
Settings.data.bar.showActiveWindowIcon = checked
}
}
NToggle {
label: "Show System Info"
description: "Display system statistics (CPU, RAM, Temperature)."