Business-Time : Geri Sayım Uygulaması

Başlatan mhmtkrktr, 08 Şubat 2018 - 00:32:09

« önceki - sonraki »

0 Üyeler ve 1 Ziyaretçi konuyu incelemekte.

mhmtkrktr

Notlar:
gtkdialog paketinin kurulu olması gerekir.
vlc (medya player) kurulu ise bilgisayardan alarm için ses dosyası seçmeye izin verir. Vlc kurulu değil veya herhangi bir ses dosya seçilmemişse, uygulama kendisi alarm sesi üretir.
Dosya seçiminde sadece ses dosyası seçilmesine izin verir.
Dosya seçilmişse, kapatılana kadar seçilen dosya 3 defa tekrarlanır. Sistem kendisi alarm sesi oluşturacaksa bunun sınırı yok. Kapat butonuna basana kadar 5 saniyede bir 4 tekrar yapacaktır.
Alarm sırasında sistem sesi %90 'a yükseltilir.
Zaman aralığı en fazla 300 dakika (5 saat) ile sınırlandırıldı. Zaman girişi bundan daha büyük seçilir veya harf\sembol içeren giriş yapılırsa başlat butonu pasif konuma geçecektir.
45 saniye içerisinde giriş yapılıp başlatılmamışsa, bir kez bip sesi verecek ve kapanacaktır.
Uygulama başlar başlamaz rakam girişi yapılabilir, fakat enter ve space tuşları seçimi silecektir. Başlatmanın fare ile yapılması gerekiyor. (bunu henüz çözemedim)

Uygulama içinde kullanılan *.gif ve *.png dosyaları aşağıda ki sitelerden alınmıştır.
business-time.png : https://www.flaticon.com/free-icon/sand-clock_183220
alert.gif : http://clubpenguin.wikia.com/wiki/File:Zootopia_Party_Alert_emoticon.gif
sand-clock.gif : http://www.livepencil.com/mambers/imagesmem/animations/anim_bajar/sand_clock.html


Kurulum :
cd ~ ; wget -c https://bitbucket.org/andronovo/multihead/downloads/business-time.tar.xz ; tar -Jxvf business-time.tar.xz ; cd business-time ; ./kur ; cd

Kaldırma :
cd ~ ; wget -c https://bitbucket.org/andronovo/multihead/downloads/business-time.tar.xz ; tar -Jxvf business-time.tar.xz ; cd business-time ; ./kaldır ; cd


Önemli : Uygulamayı denemek veya kullanmak isterseniz, yukarıda ki komutlarla kurup çalıştırabilirsiniz. Pixmap ögeleri içerdiği için, aşağıda ki kod sadece kod örneği oluşturmak içindir.

#!/usr/bin/bash
#
#

  source ~/.config/user-dirs.dirs
  export GIF1=/usr/share/pixmaps/sand_clock.gif
  export GIF2=/usr/share/pixmaps/Alert.gif
 
  TMP_DIR=$(dirname $(mktemp -u))
  export TMP="$TMP_DIR/TIMER"
  rm -r "$TMP" 2>/dev/null; mkdir "$TMP"
 
timer_window_font() {
  echo 'style "timerfont" { font_name = "Sans '$1'" }
style "timerbtfont" { font_name = "Sans '$2'" }
widget_class "*<GtkButton>.GtkLabel" style "timerbtfont"
class "GtkWidget" style "timerfont"' > ${TMP}/font
}; export -f timer_window_font

  timer_window_font 32 17

  export GTK2_RC_FILES=${TMP}/font

  [[ $(type vlc 2>/dev/null) ]] && VLC=true || VLC=false
echo 0 >${TMP}/auf ; echo > ${TMP}/time

volume_level() {
  VLM=$(amixer get Master | \
  grep -oP '(?<=\[).*(?=%)'|head -1)
  [[ $VLM -le 85 ]] && amixer sset Master 90% &>/dev/null
}; export -f volume_level

stop_play() {
  PSX=$(ps aux | grep -v grep | grep 'play-and-exit')
[[ -n $PSX ]] && kill -9 $(awk '{print $2}' <<<$PSX)
}; export -f stop_play

close_alert_play() {
  (speaker-test -t sine -f 1100 -S 95 &>/dev/null) &
PID=$! ; sleep .5; kill -9 $PID &>/dev/null
}; export -f close_alert_play

alert_play() {
  while :; do
  for (( i=1; i<=4; i++ )); do
(speaker-test -t sine -f 3100 -S 95 &>/dev/null) &
PID=$! ; sleep .4; kill -9 $PID &>/dev/null
sleep 1.2
[[ -f ${TMP}/timer_stop ]] && { break; exit; }
  done
  [[ -f ${TMP}/timer_stop ]] && { break; exit; } || sleep 5
  done
}; export -f alert_play

file_play() {
  for (( i=1; i<=3; i++ )); do
  cvlc --play-and-exit "$(cat ${TMP}/soundf)" &>/dev/null
  wait ; sleep 2
[[ -f ${TMP}/timer_stop ]] && { break; exit; }
  done
}; export -f file_play

sound_play() {
volume_level
  if [[ -f "$(cat ${TMP}/soundf 2>/dev/null)" && "$(type vlc 2>/dev/null)" ]]
  then
file_play & disown
sleep 3
PSX=$(ps aux | grep -v grep | grep 'play-and-exit')
[[ -z $PSX ]] && alert_play &
  else
alert_play &
  fi
}; export -f sound_play

chooser_file() {
  if [[ -f "$CHS" ]]; then
AUF=$(file -ib "$CHS"|grep 'audio/.*;')
if [[ -n $AUF ]]; then
echo 1 >${TMP}/auf
else
echo 0 >${TMP}/auf
fi
  else
echo 0 >${TMP}/auf
  fi
}; export -f chooser_file


CHOOSER='
<window title="Müzik Dosyası Seçin" resizable="false">
<vbox border-width="10">
<chooser>
<variable>CHS</variable>
<default>"'$XDG_MUSIC_DIR'"</default>
<width>500</width>
<height>270</height>
<action when="selection-changed">chooser_file</action>
<action when="current-folder-changed">chooser_file</action>
<action when="update-preview">enable:TMR2</action>
</chooser>
<hbox>
<button width-request="80" height-request="30">
<label>"Tamam"</label>
<variable>CBT</variable>
<action>echo $CHS >'"${TMP}"'/soundf</action>
<action>exit:EXIT</action>
</button>
<button cancel></button>
</hbox>
</vbox>
<timer milliseconds="true" interval="20" visible="false">
<sensitive>false</sensitive>
<action condition="command_is_true(
[[ $(cat '"${TMP}"'/auf) -eq 1 ]] && echo true)">enable:CBT</action>
<action condition="command_is_true(
[[ $(cat '"${TMP}"'/auf) -eq 0 ]] && echo true)">disable:CBT</action>
<variable>TMR2</variable>
</timer>
<action signal="show">disable:CBT</action>
</window>
'

TIMER='
<window icon-name="appointment-soon" title="" border-width="20" border-height="10" width-request="190" height-request="217" modal="true" resizable="false">
  <vbox>
      <vbox>
<vbox>
<eventbox  width-request="190" height-request="9">
<text><label>" "</label></text>
</eventbox>
<edit editable="true" space-expand="true" space-fill="true"
hscrollbar-policy="2" vscrollbar-policy="2" justification="2"
wrap-mode="1" cursor-visible="false">
<sensitive>true</sensitive>
<variable>EDIT</variable>
<height>40</height>
<width>15</width>
<action signal="focus-in-event">clear:EDIT</action>
<action signal="focus-in-event">disable:BTS</action>
<action signal="key-press-event">removeselected:EDIT</action>
<action signal="key-press-event"
condition="command_is_true(
[[ $KEY_RAW = 0x24 || $KEY_RAW = 0x41 ]] && echo true )">
clear:EDIT</action>
<action signal="key-release-event"
condition="command_is_true(
[[ $(grep '"'[0-9]'"' <<<$EDIT) ]] && echo true )">
enable:BTS</action>
<action signal="key-release-event"
condition="command_is_true(
[[ $(grep -i '"'[a-z]'"' <<<$EDIT) ]] && echo true )">
disable:BTS</action>
<action signal="key-release-event"
condition="command_is_true(
[[ $(grep -Ei '"'[a-z]|[0-9]'"' <<<$EDIT) ]] || echo true )">
disable:BTS</action>
<action signal="key-release-event"
condition="command_is_true(
[[ $EDIT -gt 300 ]] && echo true )">
disable:BTS</action>
</edit>
<eventbox  width-request="190" height-request="29">
<text><label>" "</label></text>
</eventbox>
</vbox>
<vbox>
<button width-request="50" height-request="35">
<input file icon="audio-x-generic-symbolic"></input>
<sensitive>'"${VLC}"'</sensitive>
<variable>SBT</variable>
<action>timer_window_font 11 12</action>
<action>gtkdialog --program=CHOOSER</action>
</button>
<eventbox  width-request="190" height-request="7">
<text><label>" "</label></text>
</eventbox>
<button width-request="150" height-request="45">
<label>"Başla"</label>
<variable>BTS</variable>
<action>disable:WTM</action>
<action>echo $EDIT >'"${TMP}"'/time</action>
<action>refresh:REMAIN</action>
<action>enable:MTM</action>
<action>hide:SELECT</action>
<action>show:FOLLOW</action>
</button>
</vbox>
<variable>SELECT</variable>
</vbox>
<vbox>
<vbox>
<pixmap>
<input file>'"$GIF1"'</input>
</pixmap>
<eventbox  width-request="190" height-request="3">
<text><label>" "</label></text>
</eventbox>
<edit editable="false" space-expand="true" space-fill="true"
vscrollbar-policy="2" justification="2" wrap-mode="1"
cursor-visible="false">
<variable>REMAIN</variable>
<height>40</height>
<width>15</width>
<input file>'"${TMP}"'/time</input>
</edit>
<eventbox  width-request="190" height-request="2">
<text><label>" "</label></text>
</eventbox>
<button width-request="150" height-request="45">
<label>"Yenile"</label>
<variable>YBT</variable>
<action>hide:FOLLOW</action>
<action>show:SELECT</action>
</button>
<timer interval="60">
<sensitive>false</sensitive>
<variable>MTM</variable>
<action>echo $(($REMAIN - 1)) >'"${TMP}"'/time</action>
<action>refresh:REMAIN</action>
<action condition="command_is_true(
[[ $(cat '"${TMP}"'/time) -eq 0 ]] && echo true)">hide:FOLLOW</action>
<action condition="command_is_true(
[[ $(cat '"${TMP}"'/time) -eq 0 ]] && echo true)">show:ALERT</action>
<action condition="command_is_true(
[[ $(cat '"${TMP}"'/time) -eq 0 ]] && echo true)">sound_play &</action>
<action condition="command_is_true(
[[ $(cat '"${TMP}"'/time) -eq 0 ]] && echo true)">disable:MTM</action>
</timer>
</vbox>
<variable>FOLLOW</variable>
</vbox>
<vbox>
<vbox>
<pixmap>
<input file>'"$GIF2"'</input>
</pixmap>
<eventbox  width-request="190" height-request="3">
<text><label>" "</label></text>
</eventbox>
<button width-request="150" height-request="45">
<label>"Kapat"</label>
<variable>CBT</variable>
<action>echo >'"${TMP}"'/timer_stop</action>
<action>stop_play</action>
<action>exit:EXIT</action>
</button>
</vbox>
<variable>ALERT</variable>
</vbox>
</vbox>
<timer interval="45" visible="false">
<sensitive>true</sensitive>
<variable>WTM</variable>
<action>close_alert_play</action>
<action>exit:EXIT</action>
</timer>
<action signal="show">disable:BTS</action>
<action signal="show">hide:FOLLOW</action>
<action signal="show">hide:ALERT</action>
<action this-is-window="escape" signal="key-press-event"
condition="command_is_true( [[ $KEY_RAW = 0x9 ]] && echo true )">
exit:EXIT</action>
</window>
'
export CHOOSER
export TIMER

  [[ "$(type gtkdialog 2>/dev/null)" ]] && nohup \
  &>/dev/null gtkdialog --program=TIMER &


## alert.gif : http://clubpenguin.wikia.com/wiki/File:Zootopia_Party_Alert_emoticon.gif
## sand-clock.gif : http://www.livepencil.com/mambers/imagesmem/animations/anim_bajar/sand_clock.html