Zren / plasma-applet-commandoutput

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

feature request: add an icon you can modify through the command #28

Open tubbadu opened 3 years ago

tubbadu commented 3 years ago

Hi, it would be great if you could add the possibility to add an icon that you could modify after the command has been launched, something like on click command: "do something; new_icon='~/images/icon.png' " others widgets automatically change it like a "on/off", but sometimes I need to evaluate the situation with a command and, reading the output, changing the icon with the more appropriate one (I tried to do this by myself modifying this and other plugins but I miserably failed XD)

Zren commented 3 years ago

If https://store.kde.org/p/1297839/ isn't useful, then you can just edit the widget to something like:

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

Plasmoid.fullRepresentation: Item {
    id: panelItem
    PlasmaCore.IconItem {
        anchors.fill: parent
        source: widget.outputText == "ON" ? "icon-on" : "icon-off"
    }
    Text { 
        id: output
        visible: false
    }
}

See the widget documentation for help: https://develop.kde.org/docs/plasma/widget/

tubbadu commented 3 years ago

that works perfectly, thank you very much! I set the icon to the value returned by the script, so that any command just has to return the path to an icon and the widget will change its icon. I also had to change line 79 to made the icon changeable by the click and the scrolled commands. Now it works exactly as I wanted! Will you ever implement this feature "officially"?

Zren commented 3 years ago

Will you ever implement this feature "officially"?

No. While related, the widget is named command output. There already exists a widget that changes state based on the command output. There's also the more complicated kargos widget for full custom behavior based on the output.

I'm glad you got it working for yourself.

Sadi58 commented 1 year ago

Could you please clarify if that code block should be added after line 199, and before the block regarding "Terminal colors", and how "on" and "off" icons can be used?