Permalink
Browse files

further changes, trying to get my dotfiles repo up to date with my ac…

…tual config
  • Loading branch information...
1 parent 6c9570c commit 9f2382f67e0eebb28ab30d1a078fea935a1ce143 @aihal committed Nov 12, 2011
Showing with 366 additions and 209 deletions.
  1. +1 −0 bin/autosuspend.sh
  2. +2 −1 bin/batteryalarm.sh
  3. +6 −0 bin/clivewrapper
  4. +0 −29 bin/colors.py
  5. +54 −0 bin/commander.rb
  6. +70 −70 bin/comparedotfiles.rb
  7. +22 −0 bin/countdown.rb
  8. +12 −0 bin/eee_external_audio_toggle.rb
  9. +78 −0 bin/eieruhr
  10. +0 −27 bin/eieruhr.sh
  11. +1 −1 { → bin}/eieruhr_zwo
  12. +10 −0 bin/make_script
  13. +2 −1 bin/scrot_ogi.sh
  14. +50 −0 bin/wecker.rb
  15. +0 −30 commander.rb
  16. +0 −12 eee_external_audio_toggle.rb
  17. +4 −4 vimperatorrc.local
  18. +31 −18 vimrc
  19. +8 −11 xinitrc
  20. +15 −5 zshrc
View
@@ -7,6 +7,7 @@ chargestate=$(echo $batterystate | cut -d ' ' -f 3 | tr -d ',')
suspend_netbook() {
mpc stop
+ killall ossxmix
killall mplayer
soundoff
pm-suspend && soundon
View
@@ -4,7 +4,8 @@ export DISPLAY=":0"
batterylevel=$(acpi -b | cut -d ' ' -f 4 | tr -d '%,')
battery_alarm() {
- zenity --warning --text="Achtung Akku ist nur noch bei ${batterylevel}%"
+# zenity --warning --text="Achtung Akku ist nur noch bei ${batterylevel}%"
+ echo "naughty.notify{text=\"Achtung: Akku ist nur noch bei ${batterylevel}%\", fg=\"#F92672\", timeout=0}" | awesome-client
}
[[ $batterylevel -le 15 ]] && battery_alarm
View
@@ -0,0 +1,6 @@
+#!/bin/bash
+# - clivewrapper
+
+echo Beginning, `date`
+clive $@ && notify-send "clivewrapper" "Download done"
+echo Done, `date`
View
@@ -1,29 +0,0 @@
-#!/usr/bin/env python
-
-fg = '\033[38;5;'
-bg = '\033[48;5;'
-
-cStrings=[]
-
-for i in range( 0, 10):
- n = str(i)
- fgstr = ' ' + fg + n + 'm' + n + ' '
- bgstr = bg + n + 'm' 'XXX'
- cStrings.append(fgstr + bgstr + '\033[0m')
-
-for i in range( 10, 100):
- n = str(i)
- fgstr = ' ' + fg + n + 'm' + n + ' '
- bgstr = bg + n + 'm' 'XXX'
- cStrings.append(fgstr + bgstr + '\033[0m')
-
-for i in range( 100, 256):
- n = str(i)
- fgstr = fg + n + 'm' + n + ' '
- bgstr = bg + n + 'm' 'XXX'
- cStrings.append(fgstr + bgstr + '\033[0m')
-
-x = 0
-while x <= 26:
- print ' '.join(cStrings[x:256:27])
- x = x + 1
View
@@ -0,0 +1,54 @@
+#!/usr/bin/ruby
+# coding: utf-8
+# commander.rb
+# Small dialog window that allows persons not familiar
+# with this computer to do some emergency tasks like
+# muting the sound or cutting off the network, in cases when
+# i'm not around and the computer is obstructive to others.
+
+class Commander
+ def initialize
+ @title="Der Commander"
+ @text="Wähle eine Aktion aus, oder “Nichts”.\nUm dieses Fenster zu verschieben, WIN-taste gedrückt halten und mit gedrückter Maustaste schieben."
+ @action_0="Nichts"
+ @action_1="Netzwerk ausschalten"
+ @action_2="Ton stummschalten (toggle aus/an)(für wenn Lautsprecher oder irgendwas eingesteckt sind)"
+ @action_3="Eingebaute Lautsprecher an/aus"
+ @action_4 = "Beende einen rsync download.\nErst diese Option versuchen, um traffic auf null zu bekommen,\nwenn das nicht hilft, dann die 'Netzwerk ausschalten' Option."
+ @action_5 = "Zeige Netzwerktraffic"
+ @action_6 = "Stelle einen einmaligen Wecker"
+ end
+
+ def askuser
+ @choice = `yad --width=800 --height=350 --title="#{@title}" --text="#{@text}" --list --separator '' --column "Aktion" "#{@action_0}" "#{@action_5}" "#{@action_1}" "#{@action_2}" "#{@action_3}" "#{@action_4}" "#{@action_6}"`.chomp
+ end
+
+ def doit
+ askuser
+ exit 0 if @choice = ""
+ logfile = '/home/ogion/.local/share/commander/log'
+ File.open(logfile, 'a') {|f|
+ f.puts("#{Time.now}: #{@choice}")
+ }
+ case @choice
+ when @action_0
+ exit 0
+ when @action_1
+ # cut_network.sh is simply netcfg all-suspend and in visudo it's allowed without password
+ system("sudo /root/cut_network.sh")
+ when @action_2
+ system("ossvol -t")
+ when @action_3
+ system("ruby ~/bin/eee_external_audio_toggle.rb")
+ when @action_4
+ system("killall rsync")
+ when @action_5
+ system("urxvtc -e bwm-ng")
+ when @action_6
+ system("/home/ogion/bin/wecker.rb")
+ end
+ end
+end
+
+command = Commander.new
+command.doit
View
@@ -3,76 +3,76 @@
filehash = Hash.new
filehash = {
- '/home/ogion/github/dotfiles/xmodmaprc' => '/home/ogion/.xmodmaprc',
- '/home/ogion/github/dotfiles/vimperatorrc' => '/home/ogion/.vimperatorrc',
- '/home/ogion/github/dotfiles/vimperatorrc.local' => '/home/ogion/.vimperatorrc.local',
- '/home/ogion/github/dotfiles/htoprc' => '/home/ogion/.htoprc',
- '/home/ogion/github/dotfiles/fonts.conf' => '/home/ogion/.fonts.conf',
- '/home/ogion/github/dotfiles/Xdefaults' => '/home/ogion/.Xdefaults',
- '/home/ogion/github/dotfiles/zshrc' => '/home/ogion/.zshrc',
- '/home/ogion/github/dotfiles/xinitrc' => '/home/ogion/.xinitrc',
- '/home/ogion/github/dotfiles/vimrc' => '/home/ogion/.vimrc',
- '/home/ogion/github/dotfiles/conkyrc' => '/home/ogion/.conkyrc',
- '/home/ogion/github/dotfiles/xmobarrc' => '/home/ogion/.xmobarrc',
- '/home/ogion/github/dotfiles/bin/autosuspend.sh' => '/home/ogion/bin/autosuspend.sh',
- '/home/ogion/github/dotfiles/bin/batteryalarm.sh' => '/home/ogion/bin/batteryalarm.sh',
- '/home/ogion/github/dotfiles/bin/checkdotfiles.pl' => '/home/ogion/bin/checkdotfiles.pl',
- '/home/ogion/github/dotfiles/bin/color_scheme.sh' => '/home/ogion/bin/color_scheme.sh',
- '/home/ogion/github/dotfiles/bin/colors.py' => '/home/ogion/bin/colors.py',
- '/home/ogion/github/dotfiles/bin/colors.sh' => '/home/ogion/bin/colors.sh',
- '/home/ogion/github/dotfiles/bin/conkystatbar.sh' => '/home/ogion/bin/conkystatbar.sh',
- '/home/ogion/github/dotfiles/bin/d20' => '/home/ogion/bin/d20',
- '/home/ogion/github/dotfiles/bin/dmenu_i3.sh' => '/home/ogion/bin/dmenu_i3.sh',
- '/home/ogion/github/dotfiles/bin/dwm_script.sh' => '/home/ogion/bin/dwm_script.sh',
- '/home/ogion/github/dotfiles/bin/eieruhr.sh' => '/home/ogion/bin/eieruhr.sh',
- '/home/ogion/github/dotfiles/bin/firefox_devshm.sh' => '/home/ogion/bin/firefox_devshm.sh',
- '/home/ogion/github/dotfiles/bin/gosleep' => '/home/ogion/bin/gosleep',
- '/home/ogion/github/dotfiles/bin/gosleep.sh' => '/home/ogion/bin/gosleep.sh',
- '/home/ogion/github/dotfiles/bin/i3statbar.sh' => '/home/ogion/bin/i3statbar.sh',
- '/home/ogion/github/dotfiles/bin/i3wsbar.sh' => '/home/ogion/bin/i3wsbar.sh',
- '/home/ogion/github/dotfiles/bin/make_script' => '/home/ogion/bin/make_script',
- '/home/ogion/github/dotfiles/bin/mostused_dmenu.sh' => '/home/ogion/bin/mostused_dmenu.sh',
- '/home/ogion/github/dotfiles/bin/mpd_by_dmenu.sh' => '/home/ogion/bin/mpd_by_dmenu.sh',
- '/home/ogion/github/dotfiles/bin/namegen.py' => '/home/ogion/bin/namegen.py',
- '/home/ogion/github/dotfiles/bin/ogidmenu.sh' => '/home/ogion/bin/ogidmenu.sh',
- '/home/ogion/github/dotfiles/bin/pingtester.sh' => '/home/ogion/bin/pingtester.sh',
- '/home/ogion/github/dotfiles/bin/pwc.pl' => '/home/ogion/bin/pwc.pl',
- '/home/ogion/github/dotfiles/bin/radio.pl' => '/home/ogion/bin/radio.pl',
- '/home/ogion/github/dotfiles/bin/rootterm' => '/home/ogion/bin/rootterm',
- '/home/ogion/github/dotfiles/bin/scrot_ogi.sh' => '/home/ogion/bin/scrot_ogi.sh',
- '/home/ogion/github/dotfiles/bin/trayer2' => '/home/ogion/bin/trayer2',
- '/home/ogion/github/dotfiles/bin/trayer3' => '/home/ogion/bin/trayer3',
- '/home/ogion/github/dotfiles/bin/watcher' => '/home/ogion/bin/watcher',
- '/home/ogion/github/dotfiles/bin/watcher.py' => '/home/ogion/bin/watcher.py',
- '/home/ogion/github/dotfiles/bin/watcher.sh' => '/home/ogion/bin/watcher.sh',
- '/home/ogion/github/dotfiles/bin/comparedotfiles.rb' => '/home/ogion/bin/comparedotfiles.rb',
- '/home/ogion/github/dotfiles/i3/config' => '/home/ogion/.i3/config',
- '/home/ogion/github/dotfiles/i3/dmenu' => '/home/ogion/.i3/dmenu',
- '/home/ogion/github/dotfiles/i3/dmenu_i3.sh' => '/home/ogion/.i3/dmenu_i3.sh',
- '/home/ogion/github/dotfiles/i3/i3log' => '/home/ogion/.i3/i3log',
- '/home/ogion/github/dotfiles/i3/i3statbar.sh' => '/home/ogion/.i3/i3statbar.sh',
- '/home/ogion/github/dotfiles/vim/colors/emg.vim' => '/home/ogion/.vim/colors/emg.vim',
- '/home/ogion/github/dotfiles/vim/colors/neverland.vim' => '/home/ogion/.vim/colors/neverland.vim',
- '/home/ogion/github/dotfiles/vim/colors/README.txt' => '/home/ogion/.vim/colors/README.txt',
- '/home/ogion/github/dotfiles/vim/doc/abolish.txt' => '/home/ogion/.vim/doc/abolish.txt',
- '/home/ogion/github/dotfiles/vim/doc/surround.txt' => '/home/ogion/.vim/doc/surround.txt',
- '/home/ogion/github/dotfiles/vim/doc/tags' => '/home/ogion/.vim/doc/tags',
- '/home/ogion/github/dotfiles/vim/ftdetect/pdc.vim' => '/home/ogion/.vim/ftdetect/pdc.vim',
- '/home/ogion/github/dotfiles/vim/ftdetect/tmux.vim' => '/home/ogion/.vim/ftdetect/tmux.vim',
- '/home/ogion/github/dotfiles/vimperator/colors/ogion.vimp' => '/home/ogion/.vimperator/colors/ogion.vimp',
- '/home/ogion/github/dotfiles/vim/plugin/abolish.vim' => '/home/ogion/.vim/plugin/abolish.vim',
- '/home/ogion/github/dotfiles/vim/plugin/gnupg.vim' => '/home/ogion/.vim/plugin/gnupg.vim',
- '/home/ogion/github/dotfiles/vim/plugin/repeat.vim' => '/home/ogion/.vim/plugin/repeat.vim',
- '/home/ogion/github/dotfiles/vim/plugin/surround.vim' => '/home/ogion/.vim/plugin/surround.vim',
- '/home/ogion/github/dotfiles/vim/syntax/ikiwiki.vim' => '/home/ogion/.vim/syntax/ikiwiki.vim',
- '/home/ogion/github/dotfiles/vim/syntax/mkd.vim' => '/home/ogion/.vim/syntax/mkd.vim',
- '/home/ogion/github/dotfiles/vim/syntax/nginx.vim' => '/home/ogion/.vim/syntax/nginx.vim',
- '/home/ogion/github/dotfiles/vim/syntax/pdc.vim' => '/home/ogion/.vim/syntax/pdc.vim',
- '/home/ogion/github/dotfiles/vim/syntax/rc9.vim' => '/home/ogion/.vim/syntax/rc9.vim',
- '/home/ogion/github/dotfiles/vim/syntax/rest.vim' => '/home/ogion/.vim/syntax/rest.vim',
- '/home/ogion/github/dotfiles/vim/syntax/tmux.vim' => '/home/ogion/.vim/syntax/tmux.vim',
- '/home/ogion/github/dotfiles/vim/syntax/vimperator.vim' => '/home/ogion/.vim/syntax/vimperator.vim',
- '/home/ogion/github/dotfiles/xmonad/xmonad.hs' => '/home/ogion/.xmonad/xmonad.hs'
+ '/home/ogion/dotfiles/dotfiles/xmodmaprc' => '/home/ogion/.xmodmaprc',
+ '/home/ogion/dotfiles/dotfiles/vimperatorrc' => '/home/ogion/.vimperatorrc',
+ '/home/ogion/dotfiles/dotfiles/vimperatorrc.local' => '/home/ogion/.vimperatorrc.local',
+ '/home/ogion/dotfiles/dotfiles/htoprc' => '/home/ogion/.htoprc',
+ '/home/ogion/dotfiles/dotfiles/fonts.conf' => '/home/ogion/.fonts.conf',
+ '/home/ogion/dotfiles/dotfiles/Xdefaults' => '/home/ogion/.Xdefaults',
+ '/home/ogion/dotfiles/dotfiles/zshrc' => '/home/ogion/.zshrc',
+ '/home/ogion/dotfiles/dotfiles/xinitrc' => '/home/ogion/.xinitrc',
+ '/home/ogion/dotfiles/dotfiles/vimrc' => '/home/ogion/.vimrc',
+ '/home/ogion/dotfiles/dotfiles/conkyrc' => '/home/ogion/.conkyrc',
+ '/home/ogion/dotfiles/dotfiles/xmobarrc' => '/home/ogion/.xmobarrc',
+ '/home/ogion/dotfiles/dotfiles/bin/autosuspend.sh' => '/home/ogion/bin/autosuspend.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/batteryalarm.sh' => '/home/ogion/bin/batteryalarm.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/checkdotfiles.pl' => '/home/ogion/bin/checkdotfiles.pl',
+ '/home/ogion/dotfiles/dotfiles/bin/color_scheme.sh' => '/home/ogion/bin/color_scheme.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/colors.py' => '/home/ogion/bin/colors.py',
+ '/home/ogion/dotfiles/dotfiles/bin/colors.sh' => '/home/ogion/bin/colors.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/conkystatbar.sh' => '/home/ogion/bin/conkystatbar.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/d20' => '/home/ogion/bin/d20',
+ '/home/ogion/dotfiles/dotfiles/bin/dmenu_i3.sh' => '/home/ogion/bin/dmenu_i3.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/dwm_script.sh' => '/home/ogion/bin/dwm_script.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/eieruhr.sh' => '/home/ogion/bin/eieruhr.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/firefox_devshm.sh' => '/home/ogion/bin/firefox_devshm.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/gosleep' => '/home/ogion/bin/gosleep',
+ '/home/ogion/dotfiles/dotfiles/bin/gosleep.sh' => '/home/ogion/bin/gosleep.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/i3statbar.sh' => '/home/ogion/bin/i3statbar.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/i3wsbar.sh' => '/home/ogion/bin/i3wsbar.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/make_script' => '/home/ogion/bin/make_script',
+ '/home/ogion/dotfiles/dotfiles/bin/mostused_dmenu.sh' => '/home/ogion/bin/mostused_dmenu.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/mpd_by_dmenu.sh' => '/home/ogion/bin/mpd_by_dmenu.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/namegen.py' => '/home/ogion/bin/namegen.py',
+ '/home/ogion/dotfiles/dotfiles/bin/ogidmenu.sh' => '/home/ogion/bin/ogidmenu.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/pingtester.sh' => '/home/ogion/bin/pingtester.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/pwc.pl' => '/home/ogion/bin/pwc.pl',
+ '/home/ogion/dotfiles/dotfiles/bin/radio.pl' => '/home/ogion/bin/radio.pl',
+ '/home/ogion/dotfiles/dotfiles/bin/rootterm' => '/home/ogion/bin/rootterm',
+ '/home/ogion/dotfiles/dotfiles/bin/scrot_ogi.sh' => '/home/ogion/bin/scrot_ogi.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/trayer2' => '/home/ogion/bin/trayer2',
+ '/home/ogion/dotfiles/dotfiles/bin/trayer3' => '/home/ogion/bin/trayer3',
+ '/home/ogion/dotfiles/dotfiles/bin/watcher' => '/home/ogion/bin/watcher',
+ '/home/ogion/dotfiles/dotfiles/bin/watcher.py' => '/home/ogion/bin/watcher.py',
+ '/home/ogion/dotfiles/dotfiles/bin/watcher.sh' => '/home/ogion/bin/watcher.sh',
+ '/home/ogion/dotfiles/dotfiles/bin/comparedotfiles.rb' => '/home/ogion/bin/comparedotfiles.rb',
+ '/home/ogion/dotfiles/dotfiles/i3/config' => '/home/ogion/.i3/config',
+ '/home/ogion/dotfiles/dotfiles/i3/dmenu' => '/home/ogion/.i3/dmenu',
+ '/home/ogion/dotfiles/dotfiles/i3/dmenu_i3.sh' => '/home/ogion/.i3/dmenu_i3.sh',
+ '/home/ogion/dotfiles/dotfiles/i3/i3log' => '/home/ogion/.i3/i3log',
+ '/home/ogion/dotfiles/dotfiles/i3/i3statbar.sh' => '/home/ogion/.i3/i3statbar.sh',
+ '/home/ogion/dotfiles/dotfiles/vim/colors/emg.vim' => '/home/ogion/.vim/colors/emg.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/colors/neverland.vim' => '/home/ogion/.vim/colors/neverland.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/colors/README.txt' => '/home/ogion/.vim/colors/README.txt',
+ '/home/ogion/dotfiles/dotfiles/vim/doc/abolish.txt' => '/home/ogion/.vim/doc/abolish.txt',
+ '/home/ogion/dotfiles/dotfiles/vim/doc/surround.txt' => '/home/ogion/.vim/doc/surround.txt',
+ '/home/ogion/dotfiles/dotfiles/vim/doc/tags' => '/home/ogion/.vim/doc/tags',
+ '/home/ogion/dotfiles/dotfiles/vim/ftdetect/pdc.vim' => '/home/ogion/.vim/ftdetect/pdc.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/ftdetect/tmux.vim' => '/home/ogion/.vim/ftdetect/tmux.vim',
+ '/home/ogion/dotfiles/dotfiles/vimperator/colors/ogion.vimp' => '/home/ogion/.vimperator/colors/ogion.vimp',
+ '/home/ogion/dotfiles/dotfiles/vim/plugin/abolish.vim' => '/home/ogion/.vim/plugin/abolish.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/plugin/gnupg.vim' => '/home/ogion/.vim/plugin/gnupg.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/plugin/repeat.vim' => '/home/ogion/.vim/plugin/repeat.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/plugin/surround.vim' => '/home/ogion/.vim/plugin/surround.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/syntax/ikiwiki.vim' => '/home/ogion/.vim/syntax/ikiwiki.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/syntax/mkd.vim' => '/home/ogion/.vim/syntax/mkd.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/syntax/nginx.vim' => '/home/ogion/.vim/syntax/nginx.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/syntax/pdc.vim' => '/home/ogion/.vim/syntax/pdc.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/syntax/rc9.vim' => '/home/ogion/.vim/syntax/rc9.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/syntax/rest.vim' => '/home/ogion/.vim/syntax/rest.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/syntax/tmux.vim' => '/home/ogion/.vim/syntax/tmux.vim',
+ '/home/ogion/dotfiles/dotfiles/vim/syntax/vimperator.vim' => '/home/ogion/.vim/syntax/vimperator.vim',
+ '/home/ogion/dotfiles/dotfiles/xmonad/xmonad.hs' => '/home/ogion/.xmonad/xmonad.hs'
}
filehash.each do |key,value|
View
@@ -0,0 +1,22 @@
+#!/usr/bin/ruby
+# coding: utf-8
+# countdown.rb
+
+class Countdown
+ def initialize
+ @time = "1"
+ end
+
+ def wait
+ @time = `yad --entry --entry-text="#{@time}" --entry-label="Set countdown time in minutes" --numeric`.chomp
+ exit 0 if @time == ""
+ puts "Sleeping for #{@time.to_f*60} seconds."
+ sleep @time.to_f * 60
+ end
+end
+
+my = Countdown.new
+while true
+ my.wait
+ sleep 1
+end
@@ -0,0 +1,12 @@
+#!/usr/bin/ruby
+# coding: utf-8
+# eee_external_audio_toggle.rb
+
+case `ossmix jack.int-speaker.mode`.split.last
+when "mix3"
+ system("ossmix jack.int-speaker.mode mix2")
+ system(%Q(notify-send "toggle speakers" 'Built-in speakers are ON'))
+when "mix2"
+ system("ossmix jack.int-speaker.mode mix3")
+ system(%Q(notify-send "toggle speakers" 'Built-in speakers are OFF'))
+end
View
@@ -0,0 +1,78 @@
+#!/usr/bin/ruby
+# coding: utf-8
+# vim: ft=ruby
+# eieruhr
+
+#require 'RNotify'
+require 'slop'
+
+trap("SIGINT") { exit 0 }
+opts = Slop.parse :help => true do
+ on :s, :seconds, 'Wait for x seconds', :optional => false, :as => :integer
+ on :m, :minutes, 'Wait for x minutes', :optional => false, :as => :Integer
+ on :h, :hours, 'Wait for x hours', :optional => false, :as => :Integer
+ on :t, :type, 'The type of notification', :optional => true
+end
+
+class Eieruhr
+ def initialize(slopts)
+ @opts = slopts
+ @message = "Time over!"
+ @title = "Eieruhr"
+ @type = @opts[:type] || "notification"
+
+ @seconds = 0
+ @seconds += @opts[:seconds] if @opts[:seconds]
+ @seconds += @opts[:minutes]*60 if @opts[:minutes]
+ @seconds += @opts[:hours]*3600 if @opts[:hours]
+
+ # which mpd playlist to load
+ @playlist = "ogi"
+ end
+
+ def sleepit
+ system("date")
+ puts "Sleeping for " + @seconds.to_s + " seconds"
+ sleep @seconds
+ system("date")
+ end
+
+ def startmusic
+ # obviously, if you use alsa and not oss there will be another way,
+ # this ossmix command activates my notebook's built-in speakers
+ system("(ossmix jack.int-speaker.mode mix2 && mpc clear && mpc load #{@playlist} && mpc play) &>/dev/null")
+ end
+
+ def notify_me
+ # thus removing the dependency on RNotify
+ #Notify.init(@title)
+
+ #note = Notify::Notification.new(@title, @message, nil)
+ #note.urgency= Notify::Notification::URGENCY_CRITICAL
+ #note.timeout = Notify::Notification::EXPIRES_NEVER
+ #note.show
+ case @type
+ when "notification"
+ system(%q[notify-send -u critical -t 0 Eieruhr "Time's up! "])
+ when "yad"
+ system(%Q!yad --title "Eieruhr" --text "#{@message}" --button='gtk-ok:0'!)
+ else
+ puts "Don't have that type"
+ exit 1
+ end
+ end
+
+ def run
+ sleepit
+ startmusic
+ notify_me
+ end
+end
+
+my = Eieruhr.new(opts)
+my.run
+
+# This (exit 0) is necessary since otherwise the script would end with an exit
+# status of 1, because we didn't uninit the Notify, nor did we close the notification
+# but since we want the notification to be up until clicked away...
+exit 0
View
@@ -1,27 +0,0 @@
-#!/bin/bash
-# eieruhr - A small shell scipt that waits a specified length of time and then does mpc play
-[[ $# -eq 0 ]] && echo "$(basename $0) usage: arg to be provided: Time (man 1 sleep)" && exit 1
-
-NUMVAL=$(echo $1 | sed -e 's/[a-z].*//')
-TIMEDESC=$(echo $1 | sed -e 's/[0-9]*//')
-
-[[ ! -n $TIMEDESC ]] && TIMEDESC="s"
-
-if [[ -e /home/ogion/mpd/mpd.pid ]]
- then
- echo $(date)
-
- case $TIMEDESC in
- s) echo "Waiting $NUMVAL seconds...";;
- m) echo "Waiting $NUMVAL minutes...";;
- h) echo "Waiting $NUMVAL hours...";;
- d) echo "Waiting $NUMVAL days...";;
- *) echo "Please use a correct time designator (see man sleep)" && exit 1;;
- esac
-
- sleep $1 && mpc play >/dev/null
- echo $(date)
- echo "Time's up!" ; exit 0
- else
- echo "Please make sure mpd is running, idiot."
-fi
Oops, something went wrong.

0 comments on commit 9f2382f

Please sign in to comment.