Skip to content

Commit

Permalink
Add python files to the plasmoid package
Browse files Browse the repository at this point in the history
  • Loading branch information
rbn42 committed Oct 29, 2019
1 parent f6c74ec commit 3f0e424
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 10 deletions.
1 change: 1 addition & 0 deletions kde/install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
python build.py

rm ../panon/__pycache__ -r

kpackagetool5 -t Plasma/Applet --install plasmoid
kpackagetool5 -t Plasma/Applet --upgrade plasmoid
Expand Down
9 changes: 6 additions & 3 deletions kde/plasmoid/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
<kcfgfile name=""/>

<group name="General">
<entry name="panonServer" type="String">
<default>ws://localhost:8765</default>
<entry name="serverPort" type="Int">
<default>8738</default>
</entry>
<entry name="startServer" type="Bool">
<default>true</default>
</entry>
<entry name="reduceBass" type="Bool">
<default>true</default>
Expand All @@ -20,7 +23,7 @@
<default>true</default>
</entry>
<entry name="preferredWidth" type="Int">
<default>400</default>
<default>700</default>
</entry>

<entry name="colorSpaceHSL" type="Bool">
Expand Down
1 change: 1 addition & 0 deletions kde/plasmoid/contents/server/panon
8 changes: 8 additions & 0 deletions kde/plasmoid/contents/server/run-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
wid=$(pgrep -a python | grep panon.server | cut -d" " -f1)
echo $wid
kill $wid

cd "$(dirname "$0")"
port=$1
exec python3 -m panon.server $port
13 changes: 10 additions & 3 deletions kde/plasmoid/contents/ui/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Kirigami.FormLayout {

readonly property bool vertical: plasmoid.formFactor == PlasmaCore.Types.Vertical || (plasmoid.formFactor == PlasmaCore.Types.Planar && plasmoid.height > plasmoid.width)

property alias cfg_panonServer: panonServer.text
property alias cfg_serverPort: serverPort.text
property alias cfg_startServer: startServer.checked
property alias cfg_reduceBass: reduceBass.checked
property alias cfg_fps: fps.value

Expand All @@ -33,15 +34,21 @@ Kirigami.FormLayout {
property alias cfg_hsluvLightness :hsluvLightness.value

RowLayout {
Kirigami.FormData.label: i18nc("@title:group", "Panon server:")
Kirigami.FormData.label: i18nc("@title:group", "Panon server: ws://localhost:")
Layout.fillWidth: true

QQC2.TextField {
id: panonServer
id: serverPort
Layout.fillWidth: true
validator: IntValidator {bottom: 1; top: 30000;}
}
}

QQC2.CheckBox {
id: startServer
text: i18nc("@option:check", "Start a server along with this widget")
}

QQC2.CheckBox {
id: reduceBass
text: i18nc("@option:check", "Reduce the weight of bass")
Expand Down
21 changes: 20 additions & 1 deletion kde/plasmoid/contents/ui/Spectrum.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Qt3D.Render 2.0
import QtQuick.Layouts 1.1

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

Item{
Layout.preferredWidth: plasmoid.configuration.preferredWidth
Expand Down Expand Up @@ -367,7 +368,7 @@ void main()

WebSocket {
id: socket
url:plasmoid.configuration.panonServer
url:"ws://localhost:"+plasmoid.configuration.serverPort
onTextMessageReceived: {
messageBox= message
}
Expand Down Expand Up @@ -425,5 +426,23 @@ void main()
}
}
}

function startServer(){
if(plasmoid.configuration.startServer){
var p_ui=plasmoid.file("ui");
p_ui=p_ui.split('/')
p_ui.pop(-1)
p_ui.push('server')
p_ui.push('run-server.sh')
return 'sh '+'"'+p_ui.join('/')+'" '+plasmoid.configuration.serverPort;
}else{
return "echo do nothing";
}
}

PlasmaCore.DataSource {
engine: 'executable'
connectedSources: [startServer()]
}
}

21 changes: 20 additions & 1 deletion kde/plasmoid/contents/ui/Spectrum.template.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Qt3D.Render 2.0
import QtQuick.Layouts 1.1

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

Item{
Layout.preferredWidth: plasmoid.configuration.preferredWidth
Expand Down Expand Up @@ -34,7 +35,7 @@ Item{

WebSocket {
id: socket
url:plasmoid.configuration.panonServer
url:"ws://localhost:"+plasmoid.configuration.serverPort
onTextMessageReceived: {
messageBox= message
}
Expand Down Expand Up @@ -92,4 +93,22 @@ Item{
}
}
}

function startServer(){
if(plasmoid.configuration.startServer){
var p_ui=plasmoid.file("ui");
p_ui=p_ui.split('/')
p_ui.pop(-1)
p_ui.push('server')
p_ui.push('run-server.sh')
return 'sh '+'"'+p_ui.join('/')+'" '+plasmoid.configuration.serverPort;
}else{
return "echo do nothing";
}
}

PlasmaCore.DataSource {
engine: 'executable'
connectedSources: [startServer()]
}
}
2 changes: 1 addition & 1 deletion kde/plasmoid/metadata.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ X-KDE-ServiceTypes=Plasma/Applet
X-KDE-PluginInfo-Author=rbn42
X-KDE-PluginInfo-Email=
X-KDE-PluginInfo-Name=panon
X-KDE-PluginInfo-Version=0.2.5
X-KDE-PluginInfo-Version=0.2.6
X-KDE-PluginInfo-Website=github.com/rbn42/panon
X-KDE-PluginInfo-Category=Multimedia
X-KDE-PluginInfo-Depends=
Expand Down
2 changes: 1 addition & 1 deletion kde/plasmoid/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"ServiceTypes": [
"Plasma/Applet"
],
"Version": "0.2.5",
"Version": "0.2.6",
"Website": "github.com/rbn42/panon"
},
"X-Plasma-API": "declarativeappletscript",
Expand Down

0 comments on commit 3f0e424

Please sign in to comment.