On/Off Switch
KDE4 Extensions
Description:

On/Off Switch is a simple plasmoid that executes commands when the switch is toggled.
I wrote it change the cpufreq governor from powersave to
performance, e.g.
On-Command: solid-powermanagement set cpufreq performance
Off-Command: solid-powermanagement set cpufreq powersave

The switch image (on_off_switch.svg) and a few lines of code
were taken from toggle-compositing 0.2.3 by John Varouhakis.

Contact me/Report bugs at rpabel@gmail.com .
Last changelog:

7 years ago

/*VERSION 0.2*/
Switch can now have a name ("Label").
It is displayed in the tooltip when the
mouse hovers over the applet.
Improvements in the configuration dialog.

/*VERSION 0.1*/
First Release,
based on toggle-compositing 0.2.3
by John Varouhakis

koko2k

2 years ago

any chance to have a kde5 version?

Report

rpabel

2 years ago

I am still using KDE4. Don't know when I'll start using 5...

Report

AdaMin

5 years ago

Thank you for the great app!

The linked file has a wrong file extension. It is a tar.gz, not a tar.bz2 file.

Report

sadi

5 years ago

I wish this plasmoid could be installed directly and automatically from within KDE's plasma workspace, panel, etc.

Report

rieper

5 years ago

thank you very much! exactly what i was looking for.

knowing nothing about inkscape magic: could you give me some hints how to change the icon into a custom one?

Report

rieper

5 years ago

well, solved the inkscape part by making a svg with the two pics and set group labels to on/off.

now i am stuck at the .cpp part, since my icons are square and the original icon is not.

help is very much appreciated since i have not the slightest idea what to change in the source to make squarish icons work.

Report

FrostBlue

7 years ago

Hi I like this idea very much.
I am on Lucid and I had to move the file from

/usr/local/lib/kde4/plasma_applet_on_off_switch.so

/usr/local/share/kde4/services/plasma-applet-on_off_switch.desktop

to

/usr/lib/kde4/plasma_applet_on_off_switch.so

/usr/share/kde4/services/plasma-applet-on_off_switch.desktop

Now it shows up and lets me change the settings but I dont know where to put the icon and it gives me an error.

Icon not valid

This doesnt work

/usr/local/share/apps/desktoptheme/default/widgets/on_off_switch.svg

Please help.

Report

google01103

7 years ago

could you some how visually differentiate from the toggle composite plasmoid - maybe diff. default colors.

actually allowing custom colors would differentiate different occurrence of the plasmoid for different functions

Report

rpabel

7 years ago

I'm all for different styles, but I'm not an artist (anything I would design with Inkscape would look truly hideous). But, of course, I'd accept contributions any time...
I looked at the Plasma::Svg class again, I don't think there is any way to change the color through the class interface. I really like the idea, but I don't see how to realize yet...

Report

WildSioux

7 years ago

I just tried and it doesn't do anything. I am trying to set the command to turn on/off my wifi card(s) in my laptop.

One is internal and the other is a express card. The only way I have found to turn them on/off is with:

On: "sudo modprobe wl"
Off: "sudo modprobe -r wl"

That is my internal on in my dell laptop. Why the KDE wifi manager doesn't have this built in is beyond me.

Thanks

Report

rpabel

7 years ago

So it works for you if you put the command in quotation marks?
I don't really know what the best way to execute a generic command from a plasmoid is, so my first guess was to call something else. Right now, I take the string and call KRun::runCommand() . I don't really know what you can feed this method and I don't really see why quotation marks make any difference. I wanted to improve the widget over the weekend, I will also look into your issue then.

Report

WildSioux

7 years ago

Sorry if I caused some confusion. NO, I'm not able to run a sudo command with this. I should have been more clear in that this is a question.

That sudo command is what I run in konsole (without the quotes).

My questions; is this possible to do somehow with this on/off plasmoid? I would be cool with it if it popped up a window to enter in my password. Just so this holds and executes the command after it is entered.

Thanks

Report

xakde

7 years ago

you can always use kdesudo

Report

rpabel

7 years ago

yeah, that is probably the best way to do it, kdesudo should pop up a window and ask for you password.
I never thought to execute interactive programs with the switch, I only thought of silently executing programs. If you really need to start something with input/output or a GUI, a desktop shortcut is probably the first choice...
Alternatively, configure sudo to work without inputing your password, then it could also work with sudo...

Report

WildSioux

7 years ago

...kdesudo works!

This is how I got it to work...
On Command: kdesudo modprobe wl
Off Command: sudo modprobe -r wl

with kdesudo in the off command it wouldn't turn it off. I imagine though, that since my password was already entered for kdesudo it remains open for 10-15 minutes (I can't remember the length). That is why it just works this way.

However, I believe if it has been longer than 15 minutes and the password is closed then the sudo...command to turn it off won't work. I don't have time to test it.

Also, could you please add a box in the settings to add a "Name" for the switch. If I add multiple switches I don't know what is what. Something that if it is in the panel, on mouse hover it would show the name. And if it is on the desktop, then it could show the name above/below it.

Thanks

(I will have to test having my internal wifi card turned on for more than 15 minutes and see if the sudo...command will turn it off. My guess is no).

Report

rpabel

7 years ago

Thanks for the idea with the tooltip, I had planned to give the switch a name, but wasn't sure how to display it. I'll upload the new version in a minute.

Report

srog

7 years ago

Tested with the Kubuntu 9.10

With the commands:

On:
qdbus org.kde.powerdevil /modules/powerdevil setProfile Performance

OFF:
qdbus org.kde.powerdevil /modules/powerdevil setProfile Powersave

Working fine - Excellent idea - Thank you !!

Report

rpabel

7 years ago

Thanks for the positive feedback.
I developed and tested it on OpenSuSE 11.2, good to know it not only works-for-me(tm)

Report

7 years ago

/*VERSION 0.2*/
Switch can now have a name ("Label").
It is displayed in the tooltip when the
mouse hovers over the applet.
Improvements in the configuration dialog.

/*VERSION 0.1*/
First Release,
based on toggle-compositing 0.2.3
by John Varouhakis

Filename Version Description Filetype Packagetype License Downloads Date Filesize Install
Score 69%
69.00 Likes
31 Dislikes
Details
version
0.2
updated Dec 05 2009
added Nov 29 2009
downloads
page views 524