Little Tool written in Bash

Topics relating to MX Docs and MX Videos
Message
Author
User avatar
jeanpaulberes
Posts: 36
Joined: Wed Dec 19, 2018 11:56 am

Little Tool written in Bash

#1 Post by jeanpaulberes »

Hy all,
hereby a little tool written in pure Bash, with Zenity as GUI ...
I have also the same with Dialog as gui or even a text-based one ;-)
Just wanted to share,
Kind regards,
Jean Paul
Screenshot.png
You do not have the required permissions to view the files attached to this post.
:needcoffee:

User avatar
Jerry3904
Administrator
Posts: 21932
Joined: Wed Jul 19, 2006 6:13 am

Re: Little Tool written in Bash

#2 Post by Jerry3904 »

Nice. We use yad instead.
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
Adrian
Developer
Posts: 8266
Joined: Wed Jul 12, 2006 1:42 am

Re: Little Tool written in Bash

#3 Post by Adrian »

Jerry3904 wrote: Thu Dec 20, 2018 3:04 pm Nice. We use yad instead.
Any advantage of yad over zenity? Just curious...

User avatar
Jerry3904
Administrator
Posts: 21932
Joined: Wed Jul 19, 2006 6:13 am

Re: Little Tool written in Bash

#4 Post by Jerry3904 »

I believe the quality and options are better. One good reason though:

Code: Select all

jb@ULTRA:~
$ apt policy zenity
zenity:
  Installed: (none)
  Candidate: 3.22.0-1+b1
  Version table:
     3.22.0-1+b1 500
        500 http://debian.osuosl.org/debian stretch/main amd64 Packages
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

antiX-Dave
Developer
Posts: 372
Joined: Mon Apr 16, 2012 4:51 pm

Re: Little Tool written in Bash

#5 Post by antiX-Dave »

It seems like a nice picture but if sharing the program where do we find it?

As far as I know from memory yad was "yet another dialog" to improve on the idea of zenity and took over as zenity was being discontinued and did not have any available version packaged in the repos

skidoo
Posts: 753
Joined: Tue Sep 22, 2015 6:56 pm

Re: Little Tool written in Bash

#6 Post by skidoo »

Any advantage of yad over zenity?
zenity:
-- webkit dependency (bloat, vulnerability vector, and thankfully unneeded by any other program preinstalled in antiX)
-- is a gnome project, has received minimal "maintenance" since 2015 when they "deprecated" (castrated) its GTK2 compatitibility

yad:
++ no webkit dependency (yet)
++ is backward compatible all the way to GTK v2.16 (in other words, nearly universally usable across distros)

User avatar
jeanpaulberes
Posts: 36
Joined: Wed Dec 19, 2018 11:56 am

Re: Little Tool written in Bash

#7 Post by jeanpaulberes »

antiX-Dave wrote: Thu Dec 20, 2018 6:31 pm It seems like a nice picture but if sharing the program where do we find it?

As far as I know from memory yad was "yet another dialog" to improve on the idea of zenity and took over as zenity was being discontinued and did not have any available version packaged in the repos
Hereby the Code for the little script :
<---

#!/bin/bash
#
# Linux Bash script
# created By: Jean Paul BERES
# 11/10/2017

# Updated to show list of Removeable Applications (RC)
# Updated to run CacheCleaner from here
# 01/10/2018

# Updating Script using Zenity (Gtk) dialogs
# 02/10/2018

# Updated Script sorting first Automatic Installed Applications followed by Installed Applications
# 20/11/2018

# Temporary files for Graphical Usage
GrMenu=$(mktemp -t Mnlist.XXX)

# Function using dialog GUI, to be used within terminal mode
#function InstalledSoftware {
#dpkg -l > $SWList
#dialog --textbox $SWList 40 180
#}

#Function for creating list of Installed Applications sorted by Installed Automatic followed by Installed Applications
function InstalledSoftware {
apt list > /tmp/SWList
cat /tmp/SWList |grep "installed,automatic" > /tmp/InstalledSoftwareList
cat /tmp/SWList |grep -v "installed,automatic" > /tmp/TmpSoftware
cat /tmp/TmpSoftware |grep "installed" >> /tmp/InstalledSoftwareList
}

function RemoveableApps {
dpkg -l|grep "^rc" | zenity --text-info --title="Obsolete Packages / removeable Applications" --width 1360 --height 600
}

function GraphicalMenu {
zenity --list \
--title "Software Selection and Cleaning Tool" \
--width 400 --height 220 \
--column " " \
"Overview of installed packages" \
"Removeable Apps" \
"Create OutputList of installed packages" \
"Cache Cleaning Tool" \
"My Cleaning Tool" >$GrMenu
}

while true
do
#Menu
GraphicalMenu 2>/dev/null
# Test if input is valid, if not Quit ... Cancel is pressed
if [ $? -eq 1 ]
then
break
clear
fi

option=$(cat $GrMenu)
case $option in

"Overview of installed packages")
# Installed Applications
InstalledSoftware
cat -n /tmp/InstalledSoftwareList | zenity --text-info --title="Installed Software" --width 1360 --height 600 2>/dev/null ;;

"Removeable Apps")
# Removeable Applications
RemoveableApps ;;

"Create OutputList of installed packages")
InstalledSoftware
cat -n /tmp/InstalledSoftwareList > ~/Documents/ListOfInstalledSoftware
zenity --info --title "Installed Software" --text "List of Installed Software created" ;;

"Cache Cleaning Tool")
clear
~/Documents/CacheCleaner.sh ;;

"My Cleaning Tool")
clear
gksudo ~/Documents/MyLinuxMintCleaner.sh ;;
*)
zenity --info "Sorry, wrong selection !" ;;

esac

done

# Removing the Temporary Files
rm -f $GrMenu 2> /dev/null
rm -f /tmp/SWList 2> /dev/null
rm -f /tmp/TmpSoftware 2> /dev/null
rm -f /tmp/InstalledSoftwareList 2> /dev/null
echo -e "\n"
clear

--->
:needcoffee:

User avatar
Jerry3904
Administrator
Posts: 21932
Joined: Wed Jul 19, 2006 6:13 am

Re: Little Tool written in Bash

#8 Post by Jerry3904 »

I get a couple of errors trying to run it:

Code: Select all

$ sh jeanpaulberes.sh 
jeanpaulberes.sh: 27: jeanpaulberes.sh: function: not found

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

jeanpaulberes.sh: 32: jeanpaulberes.sh: Syntax error: "}" unexpected
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
fehlix
Developer
Posts: 10366
Joined: Wed Apr 11, 2018 5:09 pm

Re: Little Tool written in Bash

#9 Post by fehlix »

jeanpaulberes wrote: Fri Dec 21, 2018 4:50 pm Hereby the Code for the little script :
@jeanpaulberes,
please wrap your code into code-tags [code] [/code] by editing of your post, mark the code with the mouse and click on the code-tag icon </> above the editor-window.
Thanks
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

User avatar
rasat
Posts: 644
Joined: Tue Dec 19, 2017 1:19 pm

Re: Little Tool written in Bash

#10 Post by rasat »

Create OutputList of installed packages
1) There is no indication where output list was created. I had to read the script, where it went.
cat -n /tmp/InstalledSoftwareList > ~/Documents/ListOfInstalledSoftware

2) I am from the old school, good to add extension .txt (ListOfInstalledSoftware.txt)

Bash is my favourite. Arch Linux hardware detect and /etc/X11/XF86Config generator (hwd) in 2003, was in Bash. Modified from KNOPPIX live CD.

Post Reply

Return to “Documentation and videos”