#!/bin/bash
## RPJ 9.6.2023
## 8.7.2023 locales added
# 1.5.2024 more dialogs added
# 25.6.2026 some dialogs are removed 

TEXTDOMAINDIR=/usr/share/locale
TEXTDOMAIN=add-toolbar-item

yad --center --width=500 --height=30 --text-align=center --title=$"Do you want to make a custom toolbar item?" --text=$"Do you want to make a custom toolbar item?"
if [ $? = 0 ];
then
NAME=`yad --center --width=500 --height=100 --text-align=center --button=OK:0 --title=$"SET PROGRAM NAME" --text=$"PROGRAM NAME" --entry --entry-label=$"HERE" --entry-text=""`
PROG=`yad --title=$"Choose Program" --text=$"Choose Program" --title=$"Choose Program" --button=OK:0 --file --width=1000`
ICON=`cd /usr/share/icons && yad --text=$"Choose Icon" --title=$"Choose Icon" --button=OK:0 --file --width=1000`
##

cp $HOME/.icewm/toolbar $HOME/.icewm/toolbar.backup
sed -i -e '$a#' $HOME/.icewm/toolbar
{
echo "prog '$NAME' $ICON $PROG"
} > /tmp/newline.txt 
cat /tmp/newline.txt >> $HOME/.icewm/toolbar
rm /tmp/newline.txt
sleep 1
icewm -r
sleep 1
yad --center --width=500 --height=30 --text-align=center --title=$"New toolbar item is made" --button=OK:0 --text=$"New toolbar item is made"
else exit 0
fi
