--dclick-action
flag, but i can't get it to work..Code: Select all
#!/bin/bash
################################################################
# #
# Small script that lists all installed packages with option #
# to show package info and link to website. Only tested on #
# Mint 19 & 20. Depends on: apt, dpkg, yad and a browser #
# #
# Made by Koentje (lowrida007@gmail.com version 1.0 #
# #
################################################################
tmpfile="/tmp/yad-show-package.tmp"
main_width="1900"
main_height="800"
dialog_width="1050"
dialog_height="500"
dialog_font="Ubuntu Mono 12"
###############################################################################################################
############################# CHANGES AFTER THIS LINE ARE AT OWN RISK #######################################
###############################################################################################################
arch=`dpkg --print-architecture`
function info_dialog () {
package=$(echo "$input" | awk -F "|" '{print $2}')
sudo apt show "$package" > "$tmpfile"
url=$(cat "$tmpfile" | grep "Homepage:" | awk '{print $2}')
cat $tmpfile | yad --text-info --margins=6 --back=#181818\
--title=" Show package $package "\
--center --fixed --on-top --wrap\
--tail --always-print-result\
--fontname="$dialog_font"\
--text-align=left\
--width="$dialog_width" --height="$dialog_height"\
--buttons-layout=spread\
--button="OK"\
--button=" Website ":44
case $? in
44) # Open url
echo "$?: Open $url"
xdg-open $url
info_dialog
;;
*)
echo "Exit nr: $?"
;;
esac
main
}
function main () {
input=$(dpkg -l | sort -fbn | tail -n +4 | grep -F "ii" | awk -F " " '{ printf $1"\n" $2"\n" $3"\n" $4"\n"; $1=$2=$3=$4=""; printf substr($0,5)"\n" }' | yad --listening\
--list --width="$main_width" --height="$main_height"\
--title=" Show installed packages - ($arch) "\
--window-icon=utilities-system-monitor\
--center --vscoll-policy=always\
--window-icon=application\
--text-align=left\
--button=" Package Info "!help-about!" Shows more info about package ":200\
--button="gtk-close"!gtk-close!" Bye.. ":202\
--buttons-layout=spread\
--dclick-action='info_dialog'\
--add-preview\
--column-width=10 --grid-lines=both --expand-column=100 --no-markup\
--column="Inst:TEXT"\
--column="Package name:TEXT"\
--column="Version number:TEXT"\
--column="Platform:TEXT"\
--column="Short description:TEXT") # '
case $? in
200) # apt show package
echo "$?: Open info dialog"
info_dialog
;;
202) # Cancel
echo "Program halted."
exit
;;
252) # Escape exit
echo "Escaped."
exit
;;
*)
echo "Exit nr: $1"
;;
esac
}
main