Web lists-archives.com

Re: [kde-linux] how to have a plasmoid that shows the current activity name like the kashew in the top right of screen?




On 01/14/2015 09:11 AM, Kevin Krammer wrote:
On Tuesday, 2015-01-13, 18:36:45, yahoo-pier_andreit wrote:
I'm starting to use activity, but I would like to know at a glance in
wich activity I am
how to have a plasmoid that shows the current activity name like the
kashew in the top right of screen?
but in bigger and more readable characters and colors..

There is an activity switcher applet, but I am not sure if it can do the
configuration options.

Cheers,
Kevin


I saw it, but no configuration possibility, only show and switch but characters are as small as the cashew, I used stdin-plasmoid to show the activity name with tha command qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityName `qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity`
and 3seconds refresh

and a qlm plasmoid with this code:
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents


Item {
    width: 10
    height: 10
    id: mainitem
    property string userName


    PlasmaComponents.Label {

        text: i18n(userName)
	font.pointSize : 12
	color: "blue"
    }


    PlasmaCore.DataSource {
        id: whoamisource
        engine: "executable"

connectedSources: ["qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityName `qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity`"]
        onNewData:{
            mainitem.userName = qsTr("KDE Activity=") + data.stdout
        }
    }
}

but if I put in a panel it doesn't refresh tha activity name


and also a python plasmoid with this code:
# Written by Grissiom chaos.proton@xxxxxxxxx

# This script is inspired by ruby-cpufreq plasmoid and released under GPL
# license. It noly goal is to display CPU frequency. If you want to do CPU
# scaling, try PowerDevil.

# Thanks to:
# wd <wd@xxxxxxxxx> for sharing his/her script that teach me to use file object. # Wang Hoi <zealot.hoi@xxxxxxxxx> for teaching me getting font from Plasma.font()

from PyQt4.QtCore import Qt
from PyQt4.QtGui import QFontMetrics

from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript
import os

class CpuFreqDisplay(plasmascript.Applet):
	def __init__(self, parent, args = None):
		plasmascript.Applet.__init__(self, parent)

	def init(self):
		self.setHasConfigurationInterface(False)
		self.setAspectRatioMode(Plasma.IgnoreAspectRatio)

		self.ft = self.font()
		# set to a reasonable pixelSize
		self.ft.setPixelSize(30)

		# from plasmaengineexplorer, solidservice seems not working on
		# my box. So I cannot use DataEngin here...
		# signal cored machine will have /sys/devices/system/cpu/cpu0/ too.
		# FIXME: What if the box have cores with different frequency?
		# f = os.system("whoami")
		# afreq = os.system("whoami")
		# f.close()
		# self.afreq = os.system("whoami")
self.afreq = os.popen("qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityName `qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity`")
		self.cfreq = self.afreq.readline().rstrip("\n")
		# now = f.read()
		# self.afreq.sort()
		# self.cfreq = 0
		# self.update_freq()

		#self.startTimer(1000)

			
	def paintInterface(self, p, option, rect):
		p.save()
		text = "KDE Activity=" + (self.cfreq)
		self.color = Qt.blue
		p.setFont(self.ft)
		p.translate(rect.x(), rect.y())
p.scale(float(rect.width()) / p.boundingRect(rect, Qt.AlignTop | Qt.AlignLeft, text).width(), float(rect.height()) / p.boundingRect(rect, Qt.AlignTop | Qt.AlignLeft, text).height())
		p.setPen(self.color)
		# from the doc: The y-position is used as the baseline of the font.
		y = QFontMetrics(self.ft).ascent()
		p.drawText(0, y,  text)
		p.restore()

def CreateApplet(p):
	return CpuFreqDisplay(p)


but I was looking for something better...

___________________________________________________
This message is from the kde-linux mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde-linux.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.