mabox-tools/bin/yautostart

87 lines
3.1 KiB
Plaintext
Raw Permalink Normal View History

2020-02-18 17:24:18 +01:00
#!/bin/bash
2020-08-31 19:38:47 +02:00
# yautostart: Mabox XDG Autostart GUI script
# Copyright (C) 2019 napcok <napcok@gmail.com>
#
2020-02-18 17:24:18 +01:00
2020-02-29 14:17:05 +01:00
case $LANG in
pl*)
TITLE="Edytor autostartu XDG"
2022-05-03 13:05:27 +02:00
DESC="Wybierz programy/usługi, które mają być uruchamiane autamatycznie\nwraz z sesją OpenBox. <a href='https://manual.maboxlinux.org/en/configuration/autostart/'>Pomoc (online)</a>"
2020-02-29 14:17:05 +01:00
ENABLE="wł"
FILE="Plik"
NAME="Nazwa"
COMMENT="Komentarz"
2021-08-26 12:10:18 +02:00
NO_DESC=""
2020-08-26 23:15:00 +02:00
CANCEL="--button=Anuluj:1"
2020-08-31 19:38:47 +02:00
OK="--button=Zastosuj:0"
2020-02-29 14:17:05 +01:00
;;
2020-08-31 19:38:47 +02:00
es*)
TITLE="XDG Autostart Editor"
2022-05-03 13:05:27 +02:00
DESC="Elegir apps o servicios para un reinicio en sesión Openbox.\n<a href='https://manual.maboxlinux.org/es/configuration/autostart/'>Info (online)</a>"
2020-08-31 19:38:47 +02:00
ENABLE="ejecutar"
FILE="Archivo"
NAME="Nombrar"
COMMENT="Comentar"
2021-08-26 12:10:18 +02:00
NO_DESC=""
2020-08-31 19:38:47 +02:00
CANCEL="--button=Cancelar:1"
OK="--button=Aceptar:0"
;;
2020-02-29 14:17:05 +01:00
*)
2021-09-17 10:01:15 +02:00
TITLE="Mabox XDG Autostart Editor"
2022-05-03 13:05:27 +02:00
DESC="Choose apps/services to autostart with OpenBox session.\n<a href='https://manual.maboxlinux.org/en/configuration/autostart/'>Info (online)</a>"
2020-02-29 14:17:05 +01:00
ENABLE="run"
2020-03-05 01:04:46 +01:00
FILE="File"
2020-02-29 14:17:05 +01:00
NAME="Name"
COMMENT="Comment"
2021-08-26 12:10:18 +02:00
NO_DESC=""
2020-08-26 23:15:00 +02:00
CANCEL="--button=Cancel:1"
2020-08-31 19:38:47 +02:00
OK="--button=OK:0"
2020-02-29 14:17:05 +01:00
;;
esac
2020-02-18 17:24:18 +01:00
config_dir=${XDG_CONFIG_HOME:-$HOME/.config}
# Copy only new files from /etc/xdg/autostart/
mkdir -p $config_dir/autostart
2021-09-17 10:01:15 +02:00
#remove pamac-tray-budgie
rm $config_dir/autostart/pamac-tray-budgie.desktop
rsync -aq --ignore-existing --exclude="pamac-tray-budgie.desktop" /etc/xdg/autostart/ $config_dir/autostart/
2020-02-18 17:24:18 +01:00
# check if line starting with Hidden exist, if not add Hidden=false
for f in $config_dir/autostart/*.desktop; do
grep -q "Hidden=" $f && echo "yes" || echo "Hidden=false" >> $f
done
results=$(mktemp --tmpdir autostart.XXXXXXXXXX)
for f in $config_dir/autostart/*.desktop; do
[ "$(grep -m 1 -e '^[[:blank:]]*Hidden' $f | cut -d = -f 2)" == "true" ] && echo false || echo true
echo $f
2021-08-26 12:10:18 +02:00
#grep -m 1 -e '^[[:blank:]]*Name=' $f | cut -d = -f 2
name=$(grep -m 1 -e '^[[:blank:]]*Name=' $f | cut -d = -f 2)
echo "<b>$name</b>"
2020-02-18 17:24:18 +01:00
#grep -m 1 -e '^[[:blank:]]*Exec' $f | cut -d = -f 2
comment=$(grep -m 1 -e '^[[:blank:]]*Comment=' $f | cut -d = -f 2)
[ ! -z "$comment" ] && echo "<i>${comment/&/&amp;}</i>" || echo "$NO_DESC"
2022-05-03 13:05:27 +02:00
done | yad --window-icon=distributor-logo-mabox --width=640 --height=500 --title="$TITLE" --image="gtk-execute" --uri-handler=xdg-open \
2020-03-05 01:04:46 +01:00
--text="$DESC" --list --print-all --bool-fmt="t" \
2020-08-26 23:15:00 +02:00
--checklist --column="$ENABLE:CHK" --column="$FILE:HD" --column="$NAME" --column="$COMMENT" --tooltip-column=4 $CANCEL $OK > $results
2020-02-18 17:24:18 +01:00
if [[ ${PIPESTATUS[1]} -eq 0 ]]; then
i=0
cat $results | while read line; do
eval $(echo $line | awk -F'|' '{printf "export HIDDEN=\"%s\" FILENAME=\"%s\"", $1, $2 }')
[ $HIDDEN == "true" ] && HIDDEN="false" || HIDDEN="true"
echo "Hidden=$HIDDEN, File: $FILENAME"
sed -i'.temp' -e 's/^Hidden.*$/Hidden='"$HIDDEN"'/g' $FILENAME
rm $FILENAME.temp
((i++))
done
unset NAME HIDDEN FILENAME comment
fi
rm -f $results
exit 0