Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
automatic aterm command execution wit
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
superuser
Apprentice
Apprentice


Joined: 14 Mar 2004
Posts: 166
Location: Colorado, Colorado Springs

PostPosted: Thu May 05, 2005 6:44 pm    Post subject: automatic aterm command execution wit Reply with quote

Hello,

in order to retrieve my printer's current ink level I'll have to type
Code:
sudo escputil --ink-level --new --raw-device /dev/usb/lp0
, which is quite a lot, indeed. To make things a bit more comfortable I created a menu entry that opens an aterm, which then executes the above mentioned command.
Code:
aterm -e sudo escputil --ink-level --new --raw-device /dev/usb/lp0
This does work fairly well, except for it closes the aterm when escputil's finished so I can't read the actual information!

Any hints :?:

su
Back to top
View user's profile Send private message
grad_guy
Tux's lil' helper
Tux's lil' helper


Joined: 16 Nov 2004
Posts: 109
Location: UCSD, La Jolla, CA

PostPosted: Thu May 05, 2005 8:00 pm    Post subject: Reply with quote

This is a way you can try.
Create a script file "inklevel.sh"
Code:

#!/bin/bash
#~/inklevel.sh
sudo escputil --ink-level --new --raw-device /dev/usb/lp0
sleep 10

Then
Code:
chmod +x inklevel.sh

Then
Code:
aterm -e ~/inklevel.sh
Back to top
View user's profile Send private message
kamagurka
Veteran
Veteran


Joined: 25 Jan 2004
Posts: 1026
Location: /germany/munich

PostPosted: Thu May 05, 2005 9:57 pm    Post subject: Reply with quote

A bit more elaborate is this:
Code:
#!/bin/bash
#
INKLEVEL=$(sudo escputil --ink-level --new --raw-device /dev/usb/lp0)
zenity --info --text=$INKLEVEL

You need to emerge zenity for this to work, but then everytime you call this script from the menu a gtk dialog will pop up reporting back the output of your inklevel program, and it stays until you click OK. Ain't that better than a crummy aterm?
_________________
If you loved me, you'd all kill yourselves today.
--Spider Jerusalem, the Word
Back to top
View user's profile Send private message
superuser
Apprentice
Apprentice


Joined: 14 Mar 2004
Posts: 166
Location: Colorado, Colorado Springs

PostPosted: Fri May 06, 2005 2:40 pm    Post subject: Reply with quote

kamagurka,

nice idea, but in the end, it didn't work out very well, since the two " sorrounding the brackets are necessary in this case:

Code:
#!/bin/bash
# this the retrieve ink level script by mmb (use and distribute under the GPL)
tmpfile=/tmp/inklevel.$$
sudo escputil --ink-level --new --raw-device /dev/usb/lp0 >> $tmpfile
zenity --info --title="Ink levels" --text="$(sudo escputil --ink-level --new --raw-device /dev/usb/lp0)"
rm -f $tmpfile


Hope, this helps.

su
Back to top
View user's profile Send private message
kamagurka
Veteran
Veteran


Joined: 25 Jan 2004
Posts: 1026
Location: /germany/munich

PostPosted: Fri May 06, 2005 11:33 pm    Post subject: Reply with quote

What is that tmpfile doing in there?
_________________
If you loved me, you'd all kill yourselves today.
--Spider Jerusalem, the Word
Back to top
View user's profile Send private message
superuser
Apprentice
Apprentice


Joined: 14 Mar 2004
Posts: 166
Location: Colorado, Colorado Springs

PostPosted: Sat May 07, 2005 10:18 am    Post subject: Reply with quote

Yup, it's not necessary. I could have equally well replaced it with the sudo command, but I found it a bit cleaner in this script to divide it into two different lines[/code]:
Code:
#!/bin/bash
# This the retrieve ink level script by MMB (use and distribute under the GPL), thanks to kamagurka from Gentoo forums

tmpfile=/tmp/inklevel.$$

# sudo escputil --ink-level --new --raw-device /dev/lp0 >> $tmpfile
# if you have a parallel port printer, please uncomment the line above (L6) and comment out the next (L8)
sudo escputil --ink-level --new --raw-device /dev/usb/lp0 >> $tmpfile

zenity --info --title="Ink levels" --text="$(cat $tmpfile)"
rm -f $tmpfile
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum