#!/bin/bash
##
## RJP 27.3.2024
# An alternative way to check, install and remove packages
#
# 2.4.2024 Version for PCLinuxOS
# 3.4.2024 small improments
# 29.5.2026 apt-get changed with dnf and package selection updated. Also hold option added install and remove entries
# This is using ftp.fau.de repo, which shout be the same as apt-get repo
# 2.6.2026 Fork from pclos-helper
# 3.6.2026 More smoother and faster list files for list sections
# 5.6.2026 version for PCLinuxOS 2026 where apt has removed. Also paint and photo programs added to listing sections
# 16.6.2026 added package cache refress feature into update section

touch ~/.Xresources
echo ' ! Use a truetype font and size.
xterm*faceName: Monospace ' | grep -xFv -f $HOME/.Xresources >> $HOME/.Xresources
echo 'xterm*faceSize: 14 ' | grep -xFv -f $HOME/.Xresources >> $HOME/.Xresources
xrdb -merge ~/.Xresources



1=$({                                   
echo '#!/bin/bash
##time=$(date "+%F-%H-%M-%S")
RPMLIST=$(rpm -qa --last > /tmp/Update_history.txt)
sleep 5
cat /tmp/Update_history.txt | yad --list --title $"Search Results" --width=1000 --height=500 --text "INFORMATION" --column "Search Results" --button=OK:1
'
} > /tmp/history) 


2=$({ 
echo '#!/bin/bash
PROGRAM=`yad --center --width=700 --height=100 --title=$"Install Program" --text-align=center --text="Program you want to install " --entry --entry-label=SEARCH --entry-text=""`
if [ $? = 0 ];
then
xterm -hold -e su -c "dnf install $PROGRAM " root 
else exit 0
fi '
} > /tmp/install) 


3=$({ 
echo '#!/bin/bash
PROGRAM=`yad --center --width=500 --height=100 --text-align=center --text="Program you want to remove" --entry --entry-label=is --entry-text=""`
if [ $? = 0 ];
then
xterm -hold -e su -c "dnf remove $PROGRAM " root
fi'
} > /tmp/remove)

4=$({ 
echo '#!/bin/bash
PROGRAM=`yad --center --width=500 --height=100 --text-align=center --text="Program you want to search" --entry --entry-label=is --entry-text=""`
if [ $? = 0 ];
then
xterm -hold -e "dnf search $PROGRAM " 
fi'
} > /tmp/search)



5=$({ 
echo '#!/bin/bash
yad --center --width=400 --height=100 --title=$"Update Manager" --text-align=center --text="Update your system?"
if [ $? = 0 ];
then
xterm -hold -e su -c "dnf makecache --refresh && dnf update && dnf upgrade " root
fi'
} > /tmp/update)

6=$({ 
echo '
#!/bin/bash
xterm -e "dnf list > /tmp/aptlist "
yad --list --width=1500 --height=500  \
--button=exit:1 \
--column="All available and installed"  < /tmp/aptlist
'
} > /tmp/available)

7=$({ 
echo '#!/bin/bash
yad  --list --title=$"Select Programs to Install" --width=800 --height=500 --checklist \
--button="Select programs and then run Install selected packages from the main menu":0 --button=Exit:1 \
--column="Select for installation" \
--column=Package < /tmp/list > /tmp/install2 \
--print-column=2 --separator= && \
--print --filename=/tmp/install2
echo $(cat /tmp/install2) > /tmp/install3
'
} > /tmp/packages)

8=$({ 
echo '#!/bin/bash
xterm -hold -e su -c "dnf install $(cat /tmp/install3) " root
sleep 1

'
} > /tmp/multi)

9=$({ 
echo 'false
chromium-browser
false
firefox
false
dillo-browser
false
otter-browser
false
seamonkey
false
opera-browser
false
palemoon-browser
false
google-chrome-browser
false
konqueror
false
links
false
lynx
false
midori-browser
false
vivaldi-browser
false
netsurf
false
filezilla
false
gftp
false
etherape
false
conky
false
icewm
false
idesk
false
gimp
false
kolourpaint
false
caja
false
pluma
false
atril
false
eom
false
engrampa
false
mate-terminal
false
caja-open-terminal
false
mate-utils
false
xterm
false
vlc
false
mpv
false
smplayer
false
handbrake
false
yt-dlp
false
gnome-mplayer
false
mplayer-gui
false
guvcview-gtk
false
kamoso
false
audacious
false
audacious-codecs
false
audacity
false
amarok
false
clementine
false
k3b
false
pdfarranger
false
geany
false
thunderbird
false
claws-mail
false
evolution
false
xsane
false
scribus
false
kdenlive
false
grsync
false
rpm-installer
false
gufw
false
task-lxde
false
task-printing
false
task-scanning
false
abiword
false
calligra
false
glabels
false
gnumeric
false
lomanager
false
ddcopy
false
balena-etcher'
} > /tmp/list)


chmod +x /tmp/history
chmod +x /tmp/install
chmod +x /tmp/remove
chmod +x /tmp/search
chmod +x /tmp/update
chmod +x /tmp/available
chmod +x /tmp/packages
chmod +x /tmp/multi
chmod +x /tmp/locale


#!/bin/bash
#
yad --form --columns=4 --rows=12 --width=1000 --title=$"EASY DNF PACKAGE HELPER" --text="EASY DNF PACKAGE HELPER:

                                                         PACKAGE LISTING SECTIONS ARE SLOW

" \
\
--field="RPM history (this takes time)":fbtn "/tmp/./history " \
--field="Program Installer":fbtn "/tmp/./install " \
--field="Program Remover":fbtn "/tmp/./remove " \
--field="Program search":fbtn "/tmp/./search " \
--field="Selection for package installation":fbtn "/tmp/./packages " \
--field="Install selected packages":fbtn "/tmp/./multi " \
--field="Install Updates":fbtn "/tmp/./update " \
--field="All available packages (this takes time)":fbtn "/tmp/./available " \
--field="List Mega packages":fbtn "sh -c 'dnf list \* | grep -e "task-mate" -e "task-lxde" -e "task-kde" -e "task-icewm" -e "task-enlightment" -e "task-lxqt" -e "task-openbox" -e "task-samba" -e "task-scanning" -e "task-printing" -e "task-multimedia" -e "task-lamp"> /tmp/mega.txt && xdg-open /tmp/mega.txt ; exec sh' " \
--field="List Audio packages":fbtn "sh -c 'dnf list \* | grep -e "amarok" -e "audacious" -e "audacity" -e "banshee" -e "clementine" -e "gradio" -e "juk" -e "mpv" -e "xmms" -e "rhythmbox" -e "xine" -e "spotify" -e "pulseaudio" > /tmp/audio.txt && xdg-open /tmp/audio.txt ; exec sh' " \
--field="List Video packages":fbtn "sh -c 'dnf list \* | grep -e "handbrake" -e "hypnotix" -e "kaffeine" -e "kodi" -e "mplayer" -e "IPTV" -e "vlc" -e "mpv" -e "xine" -e "totem" -e "xine" -e "transmageddon" -e "yt-dlp" > /tmp/video.txt && xdg-open /tmp/video.txt ; exec sh' " \
--field="List Video Editor packages":fbtn "sh -c 'dnf list \* | grep -e "avidemux" -e "cinelerra" -e "gnome-subtitles" -e "kdenlive" -e "kino" -e "lightworks" -e "lives" -e "lumiera" -e "natron" -e "pitivi" -e "recordmydesktop" -e "shotcut" -e "subtitleeditor" -e "subtitleeditor" -e "ssr" -e "ssr" > /tmp/video-editors.txt && xdg-open /tmp/video-editors.txt ; exec sh' " \
--field="List Browser packages":fbtn "sh -c 'dnf list \* | grep -e "firefox" -e "galeon" -e "iceweasel" -e "palemoon" -e "seamonkey" -e "brave" -e "chrome" -e "chromium" -e "opera" -e "vivaldi" -e "epiphany" -e "konqueror" -e "midori" -e "netsurf" -e "links" -e "lynx" > /tmp/browsers.txt && xdg-open /tmp/browsers.txt ; exec sh' " \
--field="List Email packages":fbtn "sh -c 'dnf list \* | grep -e "claws" -e "evolution" -e "kmail" -e "mailody" -e "thunderbird" -e "mutt" -e "seamonkey"  > /tmp/email.txt && xdg-open /tmp/email.txt ; exec sh' " \
--field="List Office packages":fbtn "sh -c 'dnf list \* | grep -e "libreoffice" -e "lomanager" -e "onlyoffice" -e "koffice" -e "abiword" -e "calligra" -e "gnumeric" -e "sunbird" -e "glabels" > /tmp/office.txt && xdg-open /tmp/office.txt ; exec sh' " \
--field="List Webcam packages":fbtn "sh -c 'dnf list \* | grep -e "guvcview" -e "cheese" -e "kamoso" -e "kamerka" > /tmp/webcam.txt && xdg-open /tmp/webcam.txt ; exec sh' " \
--field="List Graphicks packages":fbtn "sh -c 'dnf list \* | grep -e "gimp" -e "paint" -e "krita" -e "blender" -e "scribus" -e "inkscape" -e "pinta" -e "foto"  > /tmp/paint.txt && xdg-open /tmp/paint.txt ; exec sh' " \
--field="List Photo packages":fbtn "sh -c 'dnf list \* | grep -e "photo" -e "shotwell" -e "mirage" -e "view" -e "camera" -e "album" -e "converseen" -e "digi"  > /tmp/photo.txt && xdg-open /tmp/photo.txt ; exec sh' " \
--field="List FTP packages":fbtn "sh -c 'dnf list \* | grep -e "ftp" -e "filezilla" > /tmp/ftp.txt && xdg-open /tmp/ftp.txt ; exec sh' " \
--field="Update LibreOffice":fbtn "sh -c 'if [ ! -f /usr/bin/lomanager ]
then
yad --width=350 --center --buttons-layout=center --button=OK:1 --title=lomanager_is_not_installed
else
pkexec lomanager
fi ; exec sh' " \
--button=Exit:1  \

sleep 2
cd /tmp && rm install aptlist install2 remove available install3 results list locale update fixrepo.txt lomanager  Update_history.txt history multi packages
audio.txt mega.txt video-editors.txt browsers.txt ftp.txt office.txt video.txt email.txt graphicks.txt webcam.txt paint.txt search


