#!/bin/bash
v=171212 #sfs
. <(sed 's/[[:space:]]//g; s/\r$// ; s/-/_/g' "$HOME/.notify-osd")
#c="$HOME/.notify-osd"
#echo ${slot_allocation} ;exit
EXIT(){
#ntf sdsd
($0 &) ; pkill -f "yad --title notify-osd" ; exit
} ; export -f EXIT

W(){
echo "\
slot-allocation = dynamic
bubble-expire-timeout = 10sec
bubble-vertical-gap = 5px
bubble-horizontal-gap = 5px
bubble-corner-radius = 37,5%
bubble-icon-size = ${bubble_icon_size}px
bubble-gauge-size = 6px
bubble-width = ${bubble_width}px
bubble-background-color = $bubble_background_color
bubble-background-opacity = 90%
text-margin-size = ${text_margin_size}px
text-title-size = 100%
text-title-weight = bold
text-title-color = $text_title_color
text-title-opacity = 100%
text-body-size = 90%
text-body-weight = normal
text-body-color = $text_body_color
text-body-opacity = 100%
text-shadow-opacity = 100%
bubble-prevent-fade = 0
bubble-close-on-click = 0
bubble-as-desktop-bg = 0
" >"$HOME/.notify-osd"
}

ORIG(){
echo "\
slot-allocation = dynamic
bubble-expire-timeout = 10sec
bubble-vertical-gap = 5px
bubble-horizontal-gap = 5px
bubble-corner-radius = 37,5%
bubble-icon-size = 30px
bubble-gauge-size = 6px
bubble-width = 240px
bubble-background-color = 131313
bubble-background-opacity = 90%
text-margin-size = 10px
text-title-size = 100%
text-title-weight = bold
text-title-color = ffffff
text-title-opacity = 100%
text-body-size = 90%
text-body-weight = normal
text-body-color = eaeaea
text-body-opacity = 100%
text-shadow-opacity = 100%
bubble-prevent-fade = 0
bubble-close-on-click = 0
bubble-as-desktop-bg = 0
" >"$HOME/.notify-osd"
} ;export -f ORIG

HLP(){ 
defaultbrowser "https://launchpad.net/~leolik/+archive/ubuntu/leolik" &
}
export -f HLP

bubble_background_color="#$bubble_background_color"
text_title_color="#$text_title_color"
text_body_color="#$text_body_color"
#bubble_icon_size="$(echo $bubble_icon_size |sed 's/pcx//')"
#export bubble_background_color="000000"

n="Создать новый"
m2X="<b><big>Управление журналом системы</big></b>

По умолчанию журнал выключен для экономии ресурсов.
Автовключается при использовании параметров ядра: <i>debug , 1 , emergency</i> 
(добавляются в меню загрузки системы)"

y="$(yad \
--title "notify-osd v.$v" --center \
--window-icon=gtk-info \
--image-on-top --image="gtk-info" \
--text "$m2
" \
--form  \
--columns=1 \
--field="Фон:CLR" "$bubble_background_color" \
--field="Ширина:NUM" "$(echo $bubble_width |sed 's/pcx//')!0..3000!10" \
--field="Высота:NUM" "$(echo ${text_margin_size} |sed 's/pcx//')!0..3000!10" \
--field="Заголовок:CLR" "$text_title_color" \
--field="Текст:CLR" "$text_body_color" \
--field="Иконка:SCL" "$(echo $bubble_icon_size |sed 's/pcx//')" \
--field="Вернуть!gtk-refresh!Вернуть дефолтные настройки:FBTN" 'bash -c "ORIG ; EXIT"' \
--field="gtk-help:FBTN" 'bash -c "HLP ; EXIT"' \
--button=gtk-quit:1 \
--button="Запись + тест!gtk-save:0" \
)"
x="$?"

#--field="Текст$bubble_icon_size:SCL" "$bubble_icon_size" \
#--field="Весь журнал":FBTN 'defaultterminal -e sudo journalctl' \
#--field="Проверка":FBTN 'ntf -i "ddsd" "sds sdsd"'  \
#--field="Контролировать изменения -$bubble_background_color-":CLR '${bubble_background_color}' \
#--field="Контролировать изменения -$bubble_background_color-":CLR '#131313' \

#echo $y ;exit
bubble_background_color="`echo "$y" |awk -F"|" '{print $1}' |sed 's/^#//' | sed 's/^\(..\)..\(..\)..\(..\)..$/\1\2\3/'`"
           bubble_width="`echo "$y" |awk -F"|" '{print $2}'`"
       text_margin_size="`echo "$y" |awk -F"|" '{print $3}'`"
       text_title_color="`echo "$y" |awk -F"|" '{print $4}' |sed 's/^#//' | sed 's/^\(..\)..\(..\)..\(..\)..$/\1\2\3/'`"
        text_body_color="`echo "$y" |awk -F"|" '{print $5}' |sed 's/^#//' | sed 's/^\(..\)..\(..\)..\(..\)..$/\1\2\3/'`"
       bubble_icon_size="`echo "$y" |awk -F"|" '{print $6}'`"
#echo $bubble_icon_size
#exit

[ "$x" = "1" ] && exit
if [ "$x" = "0" ] ;then
    W ; ntf -i "Тестовое" "сообщение системы" &
fi
#$0
#echo "-$y-$?-"
$0 &
