Zren / plasma-applet-commandoutput

https://store.kde.org/p/1166510/
GNU General Public License v2.0
87 stars 18 forks source link

How to add an icon in the tray ? #56

Open HanM23 opened 3 months ago

HanM23 commented 3 months ago

Hello,

Thanks for your applet, it allows me to display the battery level, in percentage, of my mouse (a razer one) as there is no possibility with openrazer/polychromatic.

image

Now, when i was using xfce, i had also the possibility with their genmon (generic monitor) to run a script like you did, but also to modify the appearance of what is displaying in the tray with some kind of pango markup, like adding an icon next to the text, changing the font, background color and so on.

In any way, is there a possibility to add an icon, say, next to my percentage ? I have tried with no success until now.

Thank you

Zren commented 3 months ago

Maybe use an emoji? https://emojipedia.org/battery https://emojipedia.org/computer-mouse

Zren commented 3 months ago

If you really want an icon, you can copy ~/.local/share/plasma/plasmoids/com.github.zren.commandoutput/ and paste it as com.github.handm23.razerbattery. Then change the Id in metadata.json to match the folder name. Also change the Name so you can tell which widget it is.

https://github.com/Zren/plasma-applet-commandoutput/blob/master/package/metadata.json#L25

Then in main.qml edit the Text from:

https://github.com/Zren/plasma-applet-commandoutput/blob/master/package/contents/ui/main.qml#L346

        Text {
            id: output
            width: parent.width
            height: parent.height
            ...
        }

to

        RowLayout {
            width: parent.width
            height: parent.height

            Kirigami.Icon {
                source: 'battery-full'
            }

            Text {
                id: output
                // width: parent.width
                // height: parent.height
                ...
            }

        }

Install plasma-sdk and use the Icon Explorer app to find an icon. I recommend input-mouse or input-mouse-symbolic.

HanM23 commented 3 months ago

Hi @Zren

Thank you a lot for your help, it works great ! i can display an icon of my choice. Nonetheless, i have difficulties to find the right parameter in main.qml to set the correct width. I have tried to play with itemWidth, preferredWidth, but it's stucked to the same default width apparently so that the icon is displayed very well but the percentage overlaps the date/time, like so:

image

Do you know how to set the width ? Thank you