This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Running a plasma service/addon from the command line

Tags: None
(comma "," separated)
faircreek
Registered Member
Posts
2
Karma
0
Hi

Old git here, been using KDE since the early days of pre 1.0 :-), was at the second Linux Tag, mainly talking about icon design in Gimp. Anyways back to the question.

So the lock screen disallows Internet access, so the Picture of the Day doesn't work. What works is the potd for the desktop wallpaper so a symlink like this will make it work ln -s $HOME/.cache/plasmashell/plasma_engine_potd $HOME/.cache/kscreenlocker_greet/plasma_engine_potd -- however unless you use potd for you desktop wallpaper it will not get updated. I want a plain background since it doesn't disturb you when working but I want a nice pic when the screen is locked. So is there a way to run the potd from the command line, so you can update the pics?

Cheers Olof
User avatar
Rog131
Registered Member
Posts
828
Karma
10
faircreek wrote:Hi



So the lock screen disallows Internet access, so the Picture of the Day doesn't work. What works is the potd for the desktop wallpaper so a symlink like this will make it work ln -s $HOME/.cache/plasmashell/plasma_engine_potd $HOME/.cache/kscreenlocker_greet/plasma_engine_potd -- however unless you use potd for you desktop wallpaper it will not get updated. I want a plain background since it doesn't disturb you when working but I want a nice pic when the screen is locked. So is there a way to run the potd from the command line, so you can update the pics?

Cheers Olof


Hi !

Earlier KDE Reddit: https://www.reddit.com/r/kde/comments/7 ... round_not/

The POTD is using dataengines: https://cgit.kde.org/kdeplasma-addons.g ... gines/potd .
The dataengines can be used from the scripts. At this from the qml script.


POTD downloader plasmoid example

GettingStarted: https://techbase.kde.org/Development/Tu ... ingStarted

Image

This is an example - so cutting the corners ;)

Making:

$HOME/.local/share/plasma/plasmoids/potd/metadata.desktop
[Desktop Entry]
Name=POTD downloader
Comment=Download POTD images
Encoding=UTF-8
Icon=/path/to/potd.png
ServiceTypes=Plasma/Applet
Type=Service
X-KDE-PluginInfo-Name=potd
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml


$HOME/.local/share/plasma/plasmoids/potd/contents/ui/main.qml
Code: Select all
import QtQuick 2.5
import QtQuick.Window 2.2

import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kquickcontrolsaddons 2.0

Rectangle {
    id: box
    color: "black"
    border.color: "gray"
    border.width: 5
    radius: 10

    PlasmaCore.DataSource {
        id: engine
        engine: "potd"
        // sources: apod, bing, epod, flickr, natgeo, noaa
        connectedSources: ["bing"]
    }
   
    Image {
        id : preview
        anchors.margins: 10
        anchors.fill: parent
        fillMode: Image.PreserveAspectFit
    }

    QImageItem {
        id: source
        visible: false
        height: Screen.desktopAvailableHeight
        width: Screen.desktopAvailableWidth
        fillMode: Image.PreserveAspectFit
        // sources: apod, bing, epod, flickr, natgeo, noaa
        image: engine.data["bing"]["Image"]
    }
   
    Timer {
        id: slowtimer
        //6 * 60 * 60 * 1000 -> 21600000 ms
        interval: 21600000; running: true; repeat: true; triggeredOnStart: true
        onTriggered: {
            delaytimer.start()
        }
    }
   
    Timer {
        id: delaytimer
        // waiting 10s before showing the preview image - hopefully image is then downloaded
        interval: 10000; running: false; repeat: false;
        onTriggered: {
            // http://doc.qt.io/qt-5/qml-qtquick-item.html#grabToImage-method
            source.grabToImage(function(result) {
                        // optional save image to file
                        // 'saveToFile' is guessing the format by looking at file name's suffix !
                        //result.saveToFile("/path/to/name.png");
                        preview.source = result.url;
                        });
        }
    }
}
 


The plasmoid will download the wanted image with the potd engine. The image is saved to the plasma/potd cache: $HOME/.cache/plasmashell/plasma_engine_potd/<name>.

Image


Note !
There is no configuration dialogs - this is quick&dirty.
Configuration is now made by editing the main.qml code. There could be dialogs for:
- sources: apod, bing, epod, flickr, natgeo, noaa...
- download interval
- etc...


Generic script version example

Thread: Script to download bing desktops?: https://www.kubuntuforums.net/showthrea ... g-desktops

Note !
It is older. May or may not work now.
faircreek
Registered Member
Posts
2
Karma
0
Thanks Rog131,

It's a very very nice reply with examples and all. Will definitely dig in this :)...

Cheers Olof


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]