Page 1 of 1

[SOLVED] Create a desktop launcher to toggle application

Posted: 11. Jun 2011, 17:15
by Dennola4
I am using a Dell Inspiron 6000 laptop. Last night I installed i8kutils to speed the fan up. It works....temps went from 46C-50C to 42C-46C. Right now I have two desktop launchers: one that runs $ i8kfan - 1 (low speed) and one that runs $ i8kfan - 2 (high speed). I would rather have just one launcher to run a script which toggles the two commands.

I've gotten as far as creating an empty file, naming it, making it executable, opening with Geany, beginning it with #!bin/bash.....

....and that's where I'm stuck. I have been Googling for a simple script to toggle between two commands, but I can't find anything useful. Obviously I need to learn the basics of bash scripting, but in the meantime would someone like to help an eager learner to write out a few quick lines?

Thanks.

:idea:

Re: Create a desktop launcher to toggle fan speed high/low

Posted: 11. Jun 2011, 17:35
by gapan
Is there a command that you can run from a terminal and tell you if the current speed is high or low?

Re: Create a desktop launcher to toggle fan speed high/low

Posted: 11. Jun 2011, 17:59
by Dennola4
Hi Gapan,

Yes there is. Here's the man page: http://man.gnusquad.org/i8kctl/section-1/en/ Info is read from /proc/i8k which results after start-up command:

Code: Select all

 $ sudo /usr/sbin/modprobe i8k force=1
I'm not in front of my computer, but I'm pretty sure that when I enter:

Code: Select all

$ i8kfan speed
it reports either a low right-fan speed:

Code: Select all

-1 1
or a high right-fan speed:

Code: Select all

-1 2
Disclaimer: This is "remembered" output, not copied-and-pasted output. And btw, there is no left fan.



:idea:

Re: Create a desktop launcher to toggle fan speed high/low

Posted: 11. Jun 2011, 23:36
by Shador

Code: Select all

#!/bin/sh

if [ "x$(i8kfan speed)" == "x-1 1" ]; then
  i8kfan - 2
else
  i8kfan - 1
fi
Should work, if you got the output right. Couldn't exactly test it though. But there's not much to test anyway.

EDIT: Ooops. I put the i8kfan - 2 / - 1 commands the wrong way round. Sorry. :P

Re: Create a desktop launcher to toggle fan speed high/low

Posted: 12. Jun 2011, 04:40
by Dennola4
.
It works. Thank you, thank you, thank you. :!: :!: :!:

Image

-Dennis in New Orleans

Re: [SOLVED] Create a desktop launcher to toggle fan speed

Posted: 12. Jun 2011, 11:29
by Shador
Glad I could help. It was no effort anyway. :)

Re: [SOLVED] Create a desktop launcher to toggle fan speed

Posted: 13. Jun 2011, 18:52
by Dennola4
ADDENDUM:

As an exercise I made an xfce-panel launcher to toggle xpenguins (from the Salix repo). I created a file, pasted this script, made it executable, put it in my home directory, and used the path to it (/home/dennis/Scripts/toggle_xpenguins) as the xfce-panel application launcher command.

Code: Select all

#!/bin/bash
if pgrep xpenguins; then
pkill xpenguins && exit
else
xpenguins -s -t "Classic Penguins"
fi
Hopefully this will help someone else out there Googling "toggle + application + launcher" until 3am like I did. :mrgreen:

-Dennis in New Orleans

Re: [SOLVED] Create a desktop launcher to toggle application

Posted: 13. Jun 2011, 19:24
by Shador
There's already one included in the package, which is used by the applications menu entry. ;) It's named /usr/bin/xpenguins-menu.

Re: [SOLVED] Create a desktop launcher to toggle application

Posted: 13. Jun 2011, 19:32
by Dennola4
Oh....hahahahaha! I knew the menu icon started it, but it never occurred to me that it might also stop it. Turns out if you actually READ it, it says "Start/Stop Xpenguins". DOH!! :oops: :oops: :oops:

Oh well, it was a fun lesson in basic bash scripting regardless.