Announcement

Collapse
No announcement yet.

Please help w/ kdialog outputting a script result

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Please help w/ kdialog outputting a script result

    I am writing a little script to run a utility to check ink levels... and am finding some weirdness with getting it to run as root (the command needs to) from teh .desktop file (X-KDE-Username=root)...

    Code:
    #! /bin/sh
    # inky: script to check ink levels in Epson printer
    # Depends on Escputil version 5.0.2, Copyright (C) 2000-2006 Robert Krawitz
    
    # this version is for if the .desktop link is not ran as root
    # the -n switch keeps the password for this one command
    # inkremaining=$(kdesu -n -c "escputil --ink-level -r /dev/usb/lp0")
    
    # kdesu is removed if the .desktop file has inky.sh ran as root
    inkremaining=$(escputil --ink-level -r /dev/usb/lp0)
    kdialog --msgbox "$inkremaining" --icon utilities-log-viewer --caption Ink\ remaining --name inky
    As is above, the kdialog that results is made of kde3 widgets, but if i use the kdesu one I get the shiny new kde4 look (i am in kde4, so that is the intended result). Any thoughts?

    Or any general thoughts on how this could be better? (This is my first attempt at writing any script, and my education has been provided by Google Community College).

    In the kdesu version, not all the output is left justified, which is annoying...

    #2
    Re: Please help w/ kdialog outputting a script result

    Made some more changes... cleaned up the output...
    Code:
    #! /bin/sh
    # inky: script to check ink levels in Epson printer
    # Depends on Escputil version 5.0.2, Copyright (C) 2000-2006 Robert Krawitz
    # the -n switch keeps the password for this one command
    # this version is for trying grep
    inkremaining=$(kdesu -n -c "escputil --ink-level -r /dev/usb/lp0" | grep 'Ink\|Black\|Cyan\|Yellow\|Magenta')
    kdialog --msgbox "$inkremaining" --icon utilities-log-viewer --caption Ink\ levels --name inky
    I would think removing the Krawitz copyright from the output would not be an issue (if I were to package this, for example)...

    Still would like to left justify the text in teh msgbox though...

    Comment


      #3
      Re: Please help w/ kdialog outputting a script result

      Took out grep since escputil does allow for surpressing the banner...
      And broke it into multiple lines for probably no reason...
      Code:
      #! /bin/sh
      # inky: script to check ink levels in Epson printer
      # Depends on Escputil version 5.0.2, Copyright (C) 2000-2006 Robert Krawitz
      
      inkremaining=$(\
      kdesudo \
      --caption inky \
      --comment 'Inky needs the admin password' \
      -i utilities-log-viewer \
      -n \
      -c "escputil -q -s -r /dev/usb/lp0")
      
      kdialog \
      --msgbox \
      "$inkremaining" \
      --icon utilities-log-viewer \
      --caption Ink\ levels \
      --name inky

      Comment

      Working...
      X