diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2023-04-06 17:25:36 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2023-04-06 17:25:36 +0800 |
| commit | ff3dfc91aebd454323a25baf6ffd8c9145747564 (patch) | |
| tree | 32024bc96f75ca08abbf45eac7f150f5eafb39fa | |
| parent | f3235977b05980f40dea1d3acc53ed68e0825d70 (diff) | |
WIP
| -rw-r--r-- | X11/openbox/rc.xml | 16 | ||||
| -rwxr-xr-x | X11/show_timer.sh | 17 | ||||
| -rwxr-xr-x | bin/unix/timer.sh | 5 |
3 files changed, 23 insertions, 15 deletions
diff --git a/X11/openbox/rc.xml b/X11/openbox/rc.xml index f08a79c..7b923cd 100644 --- a/X11/openbox/rc.xml +++ b/X11/openbox/rc.xml | |||
| @@ -514,21 +514,7 @@ | |||
| 514 | </keybind> | 514 | </keybind> |
| 515 | <keybind key="W-t"> | 515 | <keybind key="W-t"> |
| 516 | <action name="Execute"> | 516 | <action name="Execute"> |
| 517 | <command> | 517 | <command>~/helper/X11/show_timer.sh</command> |
| 518 | sh -c ' | ||
| 519 | origin=`xdotool getactivewindow`; \ | ||
| 520 | xdotool search --name "TIMER" windowactivate || \ | ||
| 521 | alacritty --title TIMER --hold \ | ||
| 522 | -o "window.dimensions.columns=8" \ | ||
| 523 | -o "window.dimensions.lines=1" \ | ||
| 524 | -o "window.position.x=-0" \ | ||
| 525 | -o "window.position.y=0" \ | ||
| 526 | -o "window.opacity=0.6" \ | ||
| 527 | -o "font.size=40" \ | ||
| 528 | -e ~/helper/bin/unix/timer.sh SIGINT \ | ||
| 529 | "xdotool windowactivate $origin" | ||
| 530 | ' | ||
| 531 | </command> | ||
| 532 | </action> | 518 | </action> |
| 533 | </keybind> | 519 | </keybind> |
| 534 | <keybind key="W-e"> | 520 | <keybind key="W-e"> |
diff --git a/X11/show_timer.sh b/X11/show_timer.sh new file mode 100755 index 0000000..6ff405a --- /dev/null +++ b/X11/show_timer.sh | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | |||
| 3 | export origin=`xdotool getactivewindow`; \ | ||
| 4 | |||
| 5 | # If timer is set, focus to it | ||
| 6 | xdotool search --name "TIMER" windowactivate && exit 0 | ||
| 7 | |||
| 8 | # Add new window for a timer | ||
| 9 | # Use SIGINT | ||
| 10 | alacritty --title TIMER --hold \ | ||
| 11 | -o "window.dimensions.columns=8" \ | ||
| 12 | -o "window.dimensions.lines=1" \ | ||
| 13 | -o "window.position.x=-0" \ | ||
| 14 | -o "window.position.y=0" \ | ||
| 15 | -o "window.opacity=0.6" \ | ||
| 16 | -o "font.size=40" \ | ||
| 17 | -e sh -c '~/helper/bin/unix/timer.sh SIGINT "xdotool windowactivate $origin"' | ||
diff --git a/bin/unix/timer.sh b/bin/unix/timer.sh index 3abe701..152d828 100755 --- a/bin/unix/timer.sh +++ b/bin/unix/timer.sh | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #! /bin/bash | 1 | #! /bin/bash |
| 2 | # Ref: https://superuser.com/questions/611538/611582#611582 | 2 | # Ref: https://superuser.com/questions/611538/611582#611582 |
| 3 | 3 | ||
| 4 | exec 3>&1 | ||
| 5 | exec 1>/dev/tty | ||
| 6 | |||
| 4 | SIGNAL=${1:-SIGTERM} | 7 | SIGNAL=${1:-SIGTERM} |
| 5 | COMMAND="$2" | 8 | COMMAND="$2" |
| 6 | 9 | ||
| @@ -75,6 +78,8 @@ timer() { | |||
| 75 | done | 78 | done |
| 76 | } | 79 | } |
| 77 | 80 | ||
| 81 | trap 'exec 1>&3; echo $count; send-notify foo' EXIT KILL TERM STOP | ||
| 82 | |||
| 78 | while [ $count -lt $SET ]; do | 83 | while [ $count -lt $SET ]; do |
| 79 | [ $stop = true ] && sleep 0.3 && continue | 84 | [ $stop = true ] && sleep 0.3 && continue |
| 80 | timer | 85 | timer |