43 lines
1.6 KiB
Bash
Executable File
43 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
config_dir=${XDG_CONFIG_HOME:-$HOME/.config}
|
|
# Copy only new files from /etc/xdg/autostart/
|
|
mkdir -p $config_dir/autostart
|
|
rsync -aq --ignore-existing /etc/xdg/autostart/ $config_dir/autostart/
|
|
|
|
# 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
|
|
grep -m 1 -e '^[[:blank:]]*Name=' $f | cut -d = -f 2
|
|
#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 $comment || echo "brak opisu"
|
|
done | yad --width=400 --height=400 --title="Mabox XDG Autostart editor" --image="gtk-execute" \
|
|
--text="Dodaj/usuń programy z autostartu" --list --print-all --bool-fmt="t" \
|
|
--checklist --column="wł:CHK" --column="File:HD" --column="Nazwa" --column="Komentarz:HD" --tooltip-column=4 > $results
|
|
|
|
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
|
|
|