mirror of
https://github.com/kittywitch/nixfiles.git
synced 2026-02-09 04:19:19 -08:00
49 lines
978 B
QML
49 lines
978 B
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import Quickshell
|
|
import Niri 0.1
|
|
import "root:/DataSources"
|
|
import "root:/Helpers"
|
|
|
|
RowLayout {
|
|
id: root
|
|
property string title: get_text()
|
|
property string icon_path: get_icon()
|
|
property string app_id: get_app_id()
|
|
|
|
function get_app_id() {
|
|
var app_id = niri.focusedWindow?.appId;
|
|
return app_id
|
|
}
|
|
|
|
function get_text() {
|
|
var full_title = niri.focusedWindow?.title ?? "";
|
|
var shortened_title = full_title.substring(0, 20);
|
|
if (full_title.length > 20) {
|
|
shortened_title += "…"
|
|
}
|
|
return shortened_title
|
|
}
|
|
|
|
function get_icon() {
|
|
var icon = ThemeIcons.iconForAppId(app_id);
|
|
if (icon && icon !== "") {
|
|
return icon
|
|
}
|
|
}
|
|
|
|
spacing: 10
|
|
|
|
Image {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
source: icon_path
|
|
visible: title != ""
|
|
sourceSize.width: 24
|
|
sourceSize.height: 24
|
|
smooth: true
|
|
}
|
|
Text {
|
|
text: title
|
|
color: Settings.defaultFg
|
|
}
|
|
}
|