KALF Computertechniek

system tools with gtkdialog & zenity

June 2015

Please read this included README file for additional information.

The foundation of the script, first published on the PClinuxOS website, was laid in 2009 by Leich / Musonio.
There were some unfortunate syntax flaws in it and it was written with KDE and RPM in mind.

Also, such a dangerous function for "sudoers" was included, it might have killed the dog and set your house on fire!!
No foolin' around here: do not ever edit a sudoers file with any text-editor!!
It WILL break your operating-system. If you really must edit the file: use "sudo visudo" in a terminalscreen. 

Modifying and turning the script into a working model, and to make it suitable for DEB distros, was fun and educational.
The script commands are now up-to-date e.g. APT sources are now presented, and read-only, by the "inxi -r" and "apt-cache policy" command. Xorg.conf is more or less obsolete because of the excellent open-source (and proprietary) video drvers nowadays, therefore that information (if there was any altogether) has been removed.

Click on the INFO icon to view the requirements for a fully working app and choose "yes" to install the necessary dependencies, although most functions probably will work by default.

Unzip the script, including the icon subdirectory, in your "~/username/programs" directory, do a "chmod 777 programs" command to make all the scripts executable.

There is really no need to make it LAN-aware: it takes a mere  +/- 150 kB per system :-)
(that's including a whopping 96 kB's forgtkdialog scheme the icons!)

If one likes to start the scripts by commandline, then add the "programs" directory to the $PATH so it's known all-around your system, therefor edit ~/.bashrc and add "export PATH=/home/username/programs:$PATH" (without quotes).

The variables "ICONDIR=icons" and "GTKDIR=~/home/username/programs" offers an easy way to change locations without losing the Icons. (Do adjust the $PATH in .bashrc accordingly) The command "cd $GTKDIR" changes to the scripts directory.

Please, DO review the script and change some of the variables to your liking / situation: i.e. the terminal application and the editor.

IMPORTANT!! Whatever you do: KEEP the almost invisable " ' " after "export MAIN_DIALOG="  and, at the script-end, after the "<window>" statement.

All 'n all, I'm sure those irregularly used and quickly forgotten commands will come to hand with this tool.

File: gtksys v. 2.1 + gtktab v.2.1 (tabbed version) including README and icon sub-directory

Scrips edited by: info@frankkalf.nl / june 14, 2015 for Linux Mint 17.1

It's all yours now, so modify as you please and have fun. Download the script here.

 

The script (non-tabbed)

Use this listing only as a reference. The Code To HTML conversion did not comply with my CMS!

## =================================================================================================
# Please read the README file for additional information.
#
# This is a simple toolbox for DEB-based distributions.
# Click on the INFO icon to view the requirements to let it all work.
#
# Modify as you please.
#
# IMPORTANT!! Whatever you do: KEEP the almost invisable ' after "export MAIN_DIALOG="
# and at the script-end, after the "" statement.
# Edited by info@frankkalf.nl, june 2015 with Linux Mint 17.1
# Including the link to the "Tabbed" version
#===================================================================================================
# Default version: gtksys v.2.1
# ============ variables ================
EDITOR=geany                                # Choose your own editor if you like
TERM=gnome-terminal                            # Choose terminal appl. like xterm, guake, etc
LAN=10.0.0.0/24                                # Set your LAN range
ICONDIR=icons                                # Keep as "icons" subdirectory            
GTKDIR=/home/username/scripts                #point to the subdir where unzipped
GTKSYS=/home/username/scripts/gtksys        #point to the file where unzipped
GTKTAB=/home/username/scripts/gtktab        ##point to the file where unzipped
MODINF=/home/username/scripts/modinf        # Graphic view script on loaded modules
MODINFLS=/home/username/scripts/modinfls    # Extended list script for loaded modules
#
FILE1=/usr/bin/bum                        # Boot-Up-Manager
FILE2=/etc/fstab
FILE3=/boot/burg/burg.cfg
#FILE4=/etc/apt/sources.list            # Obsolete: see: apt-sources        
FILE5=~/.bash_aliases
FILE6=Not_used                            # Create your funtion here
FILE7=/etc/sudoers                      # DANGER: DO NOT EDIT WITH GTKDIALOG!!
FILE8=~/.bashrc
#
# ============== end vars =================
cd $GTKDIR                                # Change to the subdir where unzipped
Encoding=UTF-8
export MAIN_DIALOG='
<window allow-grow="false" window_position="1" title="Extended Non-Tabbed Toolbox 2.1" icon="$ICONDIR/system2.png">
<vbox>
  <hbox homogeneous="False">
    <frame>
    <hbox homogeneous="False">
      <hbox tooltip-text="Terminal emulator">
        <button><input file>'$ICONDIR/xterm.png'</input>
          <action>'$TERM' &</action>
        </button>  
      </hbox>
      <vbox homogeneous="True" tooltip-text="Extended Task View">

        <button tooltip-text="Tabbed version"><label>Tabbed</label>
          <action>exec '"$GTKTAB"' &</action>
          <action>rm -f /tmp/pid</action>
          <action>EXIT:ok</action>
        </button>
        
       <button tooltip-text="Extended CPU Load"><label>Glances</label>
          <action>'$TERM' --geometry 130x50 -e glances &</action>
        </button>

        <button tooltip-text="View - Kill processes"><label>Htop</label>
          <action>'$TERM' --geometry 130x50 -e htop &</action>
        </button>
      </vbox>
    </hbox>
    </frame>
    <vbox tooltip-text="Search kernel log">
      <frame View & search kernel messages>

        <button><label>Show dmesg last 50 lines</label>
          <action>dmesg | tail -50 | zenity --text-info  --width=700 --height=500 --title "dmesg" &</action>
        </button>

        <entry><variable>VAR2</variable></entry>

        <hbox tooltip-text="Search whole kernel log">
          <button><label>search</label>
            <input file>'$ICONDIR/search.png'</input>
            <action>dmesg | grep $VAR2 | zenity --text-info  --width=700 --height=500 --title "$VAR2 found in kernel messg" &</action>
          </button>

          <button><label>search & save query</label>
            <input file>'$ICONDIR/save.png'</input>
            <action>dmesg | grep $VAR2 > '$HOME'/dmesg_output_$VAR2.txt &</action>
            <action>'$EDITOR' '$HOME'/dmesg_output_$VAR2.txt</action>
          </button>
        </hbox>
        </frame>
      </vbox>
    </hbox>

<frame CLI command assistance and general lookup>
    <hbox  tooltip-text="Type command or application name">
      <text><label>for:</label></text>
      <entry><variable>VAR1</variable></entry>
    </hbox>

<hbox>

      <button tooltip-text="External commands syntax"><label>Cli Syntax Help</label>
        <action>$VAR1 -h | zenity --text-info --width=600 --height=600 --title $"Help" &</action>
      </button>
      
      <button tooltip-text="Internal commands syntax"><label>Internal Cli</label>
        <action>$VAR1 --help | zenity --text-info --width=600 --height=600 --title "GTKdialog help" &</action>
      </button>
      
      <button tooltip-text="Find variable"><label>Locate</label>
        <action>locate $VAR1 | zenity --text-info  --width=600 --height=400 --title "Occurrence of: $VAR1" &</action>
      </button>
      
      <button tooltip-text="Locate binary + source + manual files"><label>Whereis</label>
        <action>whereis $VAR1 | zenity --text-info  --width=400 --height=200 --title "Here is: $VAR1" &</action>
      </button>

      <button tooltip-text="Locate the executable file"><label>Which</label>
        <action>which $VAR1 | zenity --text-info --width=400 --height=100 --title "Executive for: $VAR1" &</action>
      </button>

      <button tooltip-text="Application version"><label>Version</label>
        <action>$VAR1 --version | zenity --text-info --width=300 --height=20 --title "Version of: $VAR1" &</action>
      </button>

    </hbox>
</frame>
    <hbox homogeneous="True">
<frame>
    <vbox>
        <button><label>Temperature</label>
          <input file>'$ICONDIR/gkrellm.png'</input>  
            <action>sensors | zenity --text-info  --width=700 --height=500 --title $"Sensors" &</action>
        </button>
        
       <button tooltip-text="Extended hardware info"><label>Hardware list </label>
          <input file>'$ICONDIR/hardware.png'</input>
               <action>gksu lshw | zenity --text-info  --width=700 --height=500 --title "Hardware information (approx. 10 secs wait)" &</action>
       </button>

        <button tooltip-text="Complete BIOS info"><label>Information</label>
          <input file>'$ICONDIR/bios.png'</input>
            <action>gksu dmidecode | zenity --text-info  --width=700 --height=500 --title "BIOS information" &</action>
        </button>

        <button tooltip-text="Current connected devices & controllers"><label>PCI devices</label>
          <input file>'$ICONDIR/pci.png'</input>
            <action>lspci | zenity --text-info  --width=700 --height=500 --title "PCI devices" &</action>
        </button>
              
        <button tooltip-text="View loaded modules on boot"><label>Loaded modules</label>
          <input file>'$ICONDIR/modules24.png'</input>
            <action>exec '$MODINF' | zenity --text-info  --width=700 --height=500 --title "Loaded modules" &</action>
        </button>
    </vbox>
</frame>

<frame>
    <vbox>
      <pixmap>
         <input file>'$ICONDIR/sysinfo.png'</input>

      </pixmap>
      
  <hbox tooltip-text="Current, which version, show PATH">
      <pixmap>
         <input file>'$ICONDIR/system.png'</input>
      </pixmap>

    <menubar>
       <menu>
          <menuitem><label>Running kernel</label>
              <action>uname -a | zenity --text-info  --width=800 --height=20 --title "Current kernel" &</action>
          </menuitem>

          <menuitem><label>Version</label>
              <action>lsb_release -as | grep Linux\ Mint | zenity --text-info  --width=60 --title "Version" &</action>
          </menuitem>
          
          <menuitem><label>Module Load Graph Version</label>
              <action>exec '$MODINFLS' &</action>
          </menuitem>

          <menuitem><label>Show Path</label>
              <action>echo '$PATH' | zenity --text-info  --width=900 --height=10 --title $"PATH" &</action>
          </menuitem>
            
          <label>Kernel Information</label>
        </menu>
    </menubar>
  </hbox>

  <hbox tooltip-text="Applications Lookup">
      <pixmap>
        <input file>'$ICONDIR/synaptic.png'</input>
      </pixmap>

    <menubar>
       <menu>
          <menuitem><label>Show All Installed Applications</label>
            <action>dpkg -l | grep ii | sort | zenity --text-info  --width=900 --height=600 --title "Installed by APT" &</action>
          </menuitem>

          <menuitem><label>Backup List of Installed Applications</label>
                <action>zenity --info --text "I will open a list of the installed DEBs in a temporary text file. \\nIf you want to keep it, save it in a different location, since the temporary file will be removed."</action>
                <action>dpkg -l | grep ii | sort > '$HOME'/temp/apt_installed.txt</action>
                    <action>'$EDITOR' '$HOME'/apt_installed.txt &</action>
          </menuitem>

          <menuitem><label>Search for Installed Applications</label>
                <action>KeyDEB=`zenity --entry --text "Enter search word:"`; dpkg -l | grep -E '^ii' | grep "$KeyDEB" | zenity --text-info  --width=900 --height=600 --title ""$KeyDEB" found in Installed apps" &</action>
          </menuitem>
            
          <menuitem><label>Search for Available Applications</label>
                <action>KeyDEB=`zenity --entry --text "Enter application:"`; apt-cache search "$KeyDEB" | zenity --text-info --width=600 --height=600 --title $""$KeyDEB" Available in Repositories" &</action>
          </menuitem>
           
          <menuitem><label>Synaptic logs</label>
                <action>gksu nemo /root/.synaptic/log &</action>
          </menuitem>
          <label>Installed Applications</label>
       </menu>
     </menubar>
  </hbox>

  <hbox tooltip-text="Hardrives, mountpoints, partitions">
        <pixmap><input file>'$ICONDIR/devices.png'</input></pixmap>
     <menubar>
       <menu>
          <menuitem><label>Hard drive UUID</label>
                <action>/sbin/blkid | zenity --text-info  --width=700 --height=500 --title "Hard Drive Blkid" &</action>
          </menuitem>

          <menuitem>
              <label>Current mount points</label>
              <action>mount | zenity --text-info  --width=700 --height=800 --title "Current mount points" & </action>
          </menuitem>

          <menuitem>
              <label>Available disk space</label>
              <action>df -h | zenity --text-info  --width=700 --height=500 --title "Available disk space"  &</action>
          </menuitem>

          <menuitem>
              <label>Connected USB devices</label>
              <action>lsusb | zenity --text-info  --width=700 --height=500 --title $"Connected USB devices" &</action>
          </menuitem>
            
          <menuitem>
              <label>List drive partitions</label>
              <action>fdisk -l | zenity --text-info  --width=700 --height=500 --title "FDISK drive partitions" &</action>
          </menuitem>
            
          <menuitem>
              <label>Edit drive partitions</label>
              <action>gksu gparted | zenity --text-info  --width=300 --height=100 --title "Partition editor" &</action>
          </menuitem>
            
            <label>Mounts and Drives</label>
       </menu>
     </menubar>
        </hbox>

        <hbox tooltip-text="Network info, speedtest">
          <pixmap>
            <input file>'$ICONDIR/eth0.png'</input>
          </pixmap>

     <menubar>
       <menu>
          
          <menuitem>
          <label>Ethernet</label>
          <action>ifconfig | zenity --text-info  --width=700 --height=500 --title $"View the ethernet interface" &</action>
          </menuitem>

          <menuitem>
            <label>Wireless Interfaces</label>
            <action>iwconfig | zenity --text-info  --width=700 --height=500 --title $"Current wireless network interface" &</action>
          </menuitem>
 
          <menuitem>
            <label>LAN Mapping</label>
            <action>nmap -sP '"$LAN"' | zenity --text-info  --width=600 --height=500 --title "Current systems on-line (aprox. 30 secs)" &</action>
          </menuitem>
          
          <menuitem>
          <label>WAN IP</label>
          <action>dig +short myip.opendns.com @resolver1.opendns.com | zenity --text-info  --width=100 --height=40 --title "World ip number" &</action>
          </menuitem>
                    
          <menuitem>
              <label>Speedtest</label>
              <action>/media/netdata/scripts/speedtest-cli | zenity --text-info --width=500 --height=300 --title "Speedtest (approx. 30 secs wait)" &</action>
          </menuitem>
          
          <label>Network Interfaces</label>
        </menu>
      </menubar>
    </hbox>

    <hbox tooltip-text="X-server, OpenGL">
      <pixmap>
        <input file>'$ICONDIR/x.png'</input>
      </pixmap>

      <menubar>
         <menu>
           <menuitem>
              <label>X-Server information</label>
              <action>xdpyinfo | zenity --text-info  --width=400 --height=500 --title $"Information about the X-server" &</action>
           </menuitem>

            <menuitem>
              <label>GLX/OpenGL Information</label>
              <action>glxinfo | zenity --text-info  --width=700 --height=500 --title $"Information about glx and opengl" & </action>
            </menuitem>

          <label>X-Server info + utilities</label>
        </menu>
     </menubar>
   </hbox>

   <hbox tooltip-text="User membership">
      <pixmap><input file>'$ICONDIR/groups.png'</input></pixmap>
     <menubar>
        <menu>
            <menuitem>
              <label>Group memberships</label>
              <action>groups | zenity --text-info  --width=700 --height=100 --title $"View group memberships" &</action>
            </menuitem>

            <menuitem>
              <label>Groups</label>
              <action>cat /etc/group | zenity --text-info  --width=700 --height=500 --title $"View Groups" &</action>
            </menuitem>

          <label>Groups Information</label>
        </menu>
     </menubar>
   </hbox>
  </vbox>
</frame>
    </hbox>
    
    <hbox>
<frame Show & Edit System Files>
    <hbox>
        <button  tooltip-text="List fstab mounts"><label>'"$FILE2"'</label>
            <action>zenity --title='"$FILE2"' --text-info --width 700 --height 600 --filename='"$FILE2"' &</action>
        </button>
          <button tooltip-text="Edit fstab mounts"><input file>'$ICONDIR/root.png'</input>
            <action>gksu '$EDITOR' '"$FILE2"' &</action>
        </button>
    </hbox>

    <hbox>
        <button tooltip-text="List Bootmanager configuration"><label>'"$FILE3"'</label>
            <action>zenity --title='"$FILE3"' --text-info --width 700 --height 400 --filename='"$FILE3"' &</action>
        </button>
        <button tooltip-text="Edit Bootmanager configuration"><input file>'$ICONDIR/root.png'</input>
            <action>gksu '$EDITOR' '"$FILE3"' &</action>
        </button>
        </hbox>

    <hbox>
        <button tooltip-text="List only. NO edit"><label>'"$FILE7"'</label>
            <action>gksu "zenity --title='"$FILE7"' --text-info --width 500 --height 400 --filename='"$FILE7"'" &</action>
        </button>
        <button tooltip-text="Sudoers README. NO edit"><input file>'$ICONDIR/nonroot.png'</input>
            <action>gksu "zenity --title='"$FILE7"' --text-info --width 600 --height 600 --filename='"/etc/sudoers.d/README"'" &</action>
        </button>
    </hbox>
    <hbox>
        <button tooltip-text="List only. cache policy sources"><label>APT Sources</label>
            <action>apt-cache policy | zenity --text-info  --width=700 --height=500 --title "All APT sources" &</action>
        </button>
        <button tooltip-text="List only. inxi -r sources"><input file>'$ICONDIR/nonroot.png'</input>
            <action>inxi -r | zenity --text-info  --width=700 --height=500 --title $"All APT sources" &</action>
        </button>
    </hbox>
    
</frame>

  <frame>
    <hbox>
    <button tooltip-text="List system startup services"><label>Boot Services</label>
          <input file>'$ICONDIR/boot24.png'</input>
            <action>service --status-all | zenity --text-info  --width=900 --height=600 --title "Startup Services" &</action>
        </button>
        <button tooltip-text="Edit with Boot-Up-Manager"><input file>'$ICONDIR/root.png'</input>
            <action>gksu '"$FILE1"' &</action>
        </button>
    </hbox>
        
    <hbox>
        <button tooltip-text="Not in use, create your own"><label>'"$FILE6"'</label>
            <action>zenity --title='"$FILE6"' --text-info --width 500 --height 400 --filename='"$FILE6"' &</action>
        </button>
        <button tooltip-text="Not in use, create your own"><input file>'$ICONDIR/nonroot.png'</input>
            <action>'$EDITOR' '"$FILE6"' &</action>
        </button>
    </hbox>

    <hbox>
        <button tooltip-text="List: starts at login and every terminal-prompt"><label>'"$FILE8"'</label>
            <action>zenity --title='"$FILE8"' --text-info --width 500 --height 600 --filename='"$FILE8"'&</action>
        </button>
        <button tooltip-text="Edit: starts at login and every terminal-prompt"><input file>'$ICONDIR/nonroot.png'</input>
            <action>'$EDITOR' '"$FILE8"' & source ~/.bashrc</action>
        </button>
    </hbox>

    <hbox>
        <button tooltip-text="List: Shortcuts for Cli commands"><label>'"$FILE5"'</label>
            <action>zenity --title='"$FILE5"' --text-info --width 500 --height 400 --filename='"$FILE5"' &</action>
        </button>
        <button tooltip-text="Edit: Shortcuts for Cli commands"><input file>'$ICONDIR/nonroot.png'</input>
            <action>'$EDITOR' '"$FILE5"' & source ~/.bashrc</action>
        </button>
     </hbox>
  </frame>
 </hbox>

  <frame>
    <hbox homogeneous="True">
        <button tooltip-text="Show or install preferred requirements"><input file>'$ICONDIR/info.png'</input>
            <action>zenity --question --text "To be able to perform all the operations, the following apps must be installed: \\n\\bum glances gnome-terminal ndmidecode lm_sensors lshw mesa-utils nmap speedtest-cli x11-utils yad zenity\\n\\nDo you want to install them if they are not already installed?"; if [ "$?" = 0 ]; then gksu "'$TERM' --noclose -e apt-get install bum glances gnome-terminal ndmidecode lm_sensors lshw mesa-utils nmap speedtest-cli x11-utils yad zenity"; fi</action>
        </button>
            <text use-markup="true"><label>"<span color='"'black'"' font-family='"'arial'"' weight='"'bold'"' size='"'large'"'><small>2015-frankkalf.nl</small></span>"</label></text>

        <button tooltip-text="Quit - Exit"><input file>'$ICONDIR/exit.png'</input>
            <action type="exit">exit</action>
        </button>
    </hbox>
    </frame>
  </vbox>
</window>
  '
gtkdialog --program=MAIN_DIALOG
Drucken