Browse Source

smoother timer

pull/1/head
parent
commit
4ab8e54cdd
4 changed files with 27 additions and 14 deletions
  1. +15
    -0
      files/bin/pipe-watcher
  2. +5
    -11
      files/bin/timer
  3. +5
    -0
      tasks/timer.yaml
  4. +2
    -3
      templates/i3/i3blocks.config.j2

+ 15
- 0
files/bin/pipe-watcher View File

@@ -0,0 +1,15 @@
#!/usr/bin/fish

set pipe $argv[1]

if test (count $argv) -ge 2
echo $argv[2]
end

if [ ! -p $pipe ]
exit 1
end

while [ -p $pipe ]
cat $pipe
end

+ 5
- 11
files/bin/timer View File

@@ -3,17 +3,11 @@
set timer_folder ~/.timer set timer_folder ~/.timer
set activity_lists_folder $timer_folder/activity.lists set activity_lists_folder $timer_folder/activity.lists
set activity_timeclock_file $timer_folder/activity.timeclock set activity_timeclock_file $timer_folder/activity.timeclock
set activity_i3blocks $timer_folder/activity.i3blocks
set activity_i3blocks_pipe $timer_folder/activity.i3blocks.fifo
set activity_current_file $timer_folder/activity.current set activity_current_file $timer_folder/activity.current
set activity_timeclock_append_log_folder $timer_folder/activity.timeclock.d set activity_timeclock_append_log_folder $timer_folder/activity.timeclock.d
set activity_timeclock_append_log_filename $activity_timeclock_append_log_folder/(date +%Y-%m-%d)-(hostname) set activity_timeclock_append_log_filename $activity_timeclock_append_log_folder/(date +%Y-%m-%d)-(hostname)



function set_i3blocks_activity_display
echo $argv[1] > $activity_i3blocks
pkill -RTMIN+1 i3blocks
end

function parse_activity_timeclock function parse_activity_timeclock
sort -k2 | uniq \ sort -k2 | uniq \
|begin |begin
@@ -42,10 +36,10 @@ function parse_activity_timeclock
end end
if [ $state = 'i' ] if [ $state = 'i' ]
echo $activity > $activity_current_file echo $activity > $activity_current_file
set_i3blocks_activity_display "<span foreground=\"#00FF00\">★ $activity</span>"
echo "<span foreground=\"#00FF00\">★ $activity</span>" > $activity_i3blocks_pipe
else else
rm $activity_current_file rm $activity_current_file
set_i3blocks_activity_display "<span foreground=\"#0000FF\">☆</span>"
echo "<span foreground=\"#0000FF\">☆</span>" > $activity_i3blocks_pipe
end end
end end


@@ -69,10 +63,12 @@ end


function begin_activity function begin_activity
echo i (date '+%Y-%m-%d %H:%M:%S') $argv >> $activity_timeclock_append_log_filename echo i (date '+%Y-%m-%d %H:%M:%S') $argv >> $activity_timeclock_append_log_filename
echo "<span foreground=\"#00FF00\">★ $argv</span>" > $activity_i3blocks_pipe
end end


function end_activity function end_activity
echo o (date '+%Y-%m-%d %H:%M:%S') >> $activity_timeclock_append_log_filename echo o (date '+%Y-%m-%d %H:%M:%S') >> $activity_timeclock_append_log_filename
echo "<span foreground=\"#0000FF\">☆</span>" > $activity_i3blocks_pipe
end end




@@ -95,5 +91,3 @@ switch $command
begin_activity 'Arbeit:Uniklinik Köln' begin_activity 'Arbeit:Uniklinik Köln'


end end

merge_timeclock_append_log

+ 5
- 0
tasks/timer.yaml View File

@@ -19,3 +19,8 @@
copy: copy:
content: "{{ default_activities | join('\n') }}" content: "{{ default_activities | join('\n') }}"
dest: "{{timer_folder}}/activity.lists/10-default" dest: "{{timer_folder}}/activity.lists/10-default"

- name: timer activity i3blocks fifo
command: mkfifo "{{timer_folder}}/activity.i3blocks.fifo"
args:
creates: "{{timer_folder}}/activity.i3blocks.fifo"

+ 2
- 3
templates/i3/i3blocks.config.j2 View File

@@ -32,10 +32,9 @@ markup=none


# activity # activity
[activity] [activity]
command=cat ~/.timer/activity.i3blocks
interval=once
command=~/bin/pipe-watcher "{{timer_folder}}/activity.i3blocks.fifo" ☆
interval=persist
markup=pango markup=pango
signal=1


# hostinfo # hostinfo
[hostinfo] [hostinfo]