[SOLVED] Create a desktop launcher to toggle application

You have a problem with Salix? Post here and we'll do what we can to help.
Post Reply
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

[SOLVED] Create a desktop launcher to toggle application

Post 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:
Last edited by Dennola4 on 13. Jun 2011, 18:53, edited 2 times in total.
There are no stupid questions.
User avatar
gapan
Salix Wizard
Posts: 6364
Joined: 6. Jun 2009, 17:40

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

Post by gapan »

Is there a command that you can run from a terminal and tell you if the current speed is high or low?
Image
Image
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

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

Post 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:
There are no stupid questions.
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

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

Post 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
Image
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

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

Post by Dennola4 »

.
It works. Thank you, thank you, thank you. :!: :!: :!:

Image

-Dennis in New Orleans
There are no stupid questions.
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

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

Post by Shador »

Glad I could help. It was no effort anyway. :)
Image
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

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

Post 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
There are no stupid questions.
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

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

Post 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.
Image
User avatar
Dennola4
Posts: 172
Joined: 7. Sep 2010, 18:25
Location: San Diego, CA, USA

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

Post 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.
There are no stupid questions.
Post Reply