View previous topic :: View next topic |
Author |
Message |
superuser Apprentice
Joined: 14 Mar 2004 Posts: 166 Location: Colorado, Colorado Springs
|
Posted: Thu May 05, 2005 6:44 pm Post subject: automatic aterm command execution wit |
|
|
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 |
|
|
grad_guy Tux's lil' helper
Joined: 16 Nov 2004 Posts: 109 Location: UCSD, La Jolla, CA
|
Posted: Thu May 05, 2005 8:00 pm Post subject: |
|
|
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 |
|
|
kamagurka Veteran
Joined: 25 Jan 2004 Posts: 1026 Location: /germany/munich
|
Posted: Thu May 05, 2005 9:57 pm Post subject: |
|
|
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 |
|
|
superuser Apprentice
Joined: 14 Mar 2004 Posts: 166 Location: Colorado, Colorado Springs
|
Posted: Fri May 06, 2005 2:40 pm Post subject: |
|
|
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 |
|
|
kamagurka Veteran
Joined: 25 Jan 2004 Posts: 1026 Location: /germany/munich
|
Posted: Fri May 06, 2005 11:33 pm Post subject: |
|
|
What is that tmpfile doing in there? _________________ If you loved me, you'd all kill yourselves today.
--Spider Jerusalem, the Word |
|
Back to top |
|
|
superuser Apprentice
Joined: 14 Mar 2004 Posts: 166 Location: Colorado, Colorado Springs
|
Posted: Sat May 07, 2005 10:18 am Post subject: |
|
|
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 |
|
|
|