История изменений
Исправление serg002, (текущая версия) :
cat /lib/systemd/system-sleep/firefox.sleep1
#!/usr/bin/env bash
vasyapetya
VAR='lib.systemd.system-sleep.firefox.sleep1.someString="yes"'
# /lib/systemd/system-sleep/firefox.sleep
DOT='.'
S=${VAR//"$DOT"}
COUNT=$(((${#VAR} - ${#S}) / ${#DOT}))
declare -a PATH
PATH=( $(echo ${VAR} | /usr/bin/tr '.' ' ') )
FILENAME="/${PATH[0]}"
for (( i = ${COUNT} ; i >= 3 ; i-- ))
do
FILENAME="${FILENAME}/${PATH[-${i}]}"
if [[ ${i} == 3 ]]
then
FILENAME="${FILENAME}/${PATH[-3]}.${PATH[-2]}"
echo ${PATH[-1]} >> ${FILENAME}
exit 0
fi
done
out:
./test.sh
./test.sh: line 58: /lib/systemd/system-sleep/firefox/firefox.sleep1: No such file or directory
Я его даже не запускал. Визуально видно, что оно не рабочее. Вот ^ запустил
Исправление serg002, :
cat /lib/systemd/system-sleep/firefox.sleep1
#!/usr/bin/env bash
vasyapetya
VAR='lib.systemd.system-sleep.firefox.sleep1.someString="yes"'
# /lib/systemd/system-sleep/firefox.sleep
DOT='.'
S=${VAR//"$DOT"}
COUNT=$(((${#VAR} - ${#S}) / ${#DOT}))
declare -a PATH
PATH=( $(echo ${VAR} | /usr/bin/tr '.' ' ') )
FILENAME="/${PATH[0]}"
for (( i = ${COUNT} ; i >= 3 ; i-- ))
do
FILENAME="${FILENAME}/${PATH[-${i}]}"
if [[ ${i} == 3 ]]
then
FILENAME="${FILENAME}/${PATH[-3]}.${PATH[-2]}"
echo ${PATH[-1]} >> ${FILENAME}
exit 0
fi
done
out:
./test.sh
./test.sh: line 58: /lib/systemd/system-sleep/firefox/firefox.sleep1: No such file or directory
Я его даже не запускал. Визуально видно, что оно не рабочее
Исходная версия serg002, :
cat /lib/systemd/system-sleep/firefox.sleep1
#!/usr/bin/env bash
vasyapetya
VAR='lib.systemd.system-sleep.firefox.sleep1.someString="yes"'
# /lib/systemd/system-sleep/firefox.sleep
DOT='.'
S=${VAR//"$DOT"}
COUNT=$(((${#VAR} - ${#S}) / ${#DOT}))
declare -a PATH
PATH=( $(echo ${VAR} | /usr/bin/tr '.' ' ') )
FILENAME="/${PATH[0]}"
for (( i = ${COUNT} ; i >= 3 ; i-- ))
do
FILENAME="${FILENAME}/${PATH[-${i}]}"
if [[ ${i} == 3 ]]
then
FILENAME="${FILENAME}/${PATH[-3]}.${PATH[-2]}"
echo ${PATH[-1]} >> ${FILENAME}
exit 0
fi
done
out:
./test.sh
./test.sh: line 58: /lib/systemd/system-sleep/firefox/firefox.sleep1: No such file or directory