From 52af58e39af8ac006c62d1788b6672966b2a9f47 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Fri, 7 Apr 2023 12:46:42 +0800 Subject: Update --- X11/openbox/rc.xml | 5 +++++ X11/rofi/pass.get | 4 ++-- X11/show_timer.sh | 22 ++++++++++++++-------- bin/task/context | 2 +- bin/unix/timer.sh | 2 ++ 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/X11/openbox/rc.xml b/X11/openbox/rc.xml index 7b923cd..14ab723 100644 --- a/X11/openbox/rc.xml +++ b/X11/openbox/rc.xml @@ -513,6 +513,11 @@ + + ~/helper/X11/show_timer.sh --context + + + ~/helper/X11/show_timer.sh diff --git a/X11/rofi/pass.get b/X11/rofi/pass.get index 18230fe..425cd62 100755 --- a/X11/rofi/pass.get +++ b/X11/rofi/pass.get @@ -40,8 +40,8 @@ set -x if [ -n "$RESULT" ]; then # Copy the given password into PRIMARY selection and kill it in 30s echo "$RESULT" | sed -n 1p | tr -d '\n' | xsel -i -t 30000 - # Copy the second line (most of the time, account name) into CLIPBOARD selection - echo "$RESULT" | sed -n 2p | tr -d '\n' | xsel -ib + # Copy the second non-empty line (most of the time, account name) into CLIPBOARD selection + echo "$RESULT" | sed -n '1d;/^./{p;q}' | tr -d '\n' | xsel -ib # And show extra message EXTRA="$(echo; echo; echo "$RESULT" | sed '1d' | sed '1{/^$/d}')" diff --git a/X11/show_timer.sh b/X11/show_timer.sh index dd6d877..149b11a 100755 --- a/X11/show_timer.sh +++ b/X11/show_timer.sh @@ -3,6 +3,12 @@ origin="$(xdotool getactivewindow)" export origin +# If --context is set, apply exit command and different color +if echo "$@" | grep -qs '\--context'; then + COMMAND_EXIT='~/helper/bin/task/context $count' + export COLOR=33 +fi + # If timer is set, focus to it and exit xdotool search --name "TIMER" windowactivate && exit 0 @@ -11,13 +17,13 @@ xdotool search --name "TIMER" windowactivate && exit 0 # Use xdotool to reactivate original window user focus # After timer is closed or finished, append time into context file alacritty --title TIMER --hold \ - -o "window.dimensions.columns=8" \ - -o "window.dimensions.lines=1" \ - -o "window.position.x=-0" \ - -o "window.position.y=0" \ - -o "window.opacity=0.6" \ - -o "font.size=40" \ - -e "$HOME"/helper/bin/unix/timer.sh \ + -o window.dimensions.columns=8 \ + -o window.dimensions.lines=1 \ + -o window.position.x=-0 \ + -o window.position.y=0 \ + -o window.opacity=0.6 \ + -o font.size=40 \ + -e ~/helper/bin/unix/timer.sh \ SIGINT \ "xdotool windowactivate $origin" \ - '~/helper/bin/task/context_spend_time.sh $count' + "$COMMAND_EXIT" diff --git a/bin/task/context b/bin/task/context index 76e1984..75597b3 100755 --- a/bin/task/context +++ b/bin/task/context @@ -18,7 +18,7 @@ if [ -n "$1" ]; then fi done <$LOG_FILE if [ "$update" = true ]; then - sed -i -E "s/^$context.*/$context\t$summary" $LOG_FILE + sed -i -E "s/^$context.*/$context\t$summary/" $LOG_FILE else echo -e "$context\t$count" >>$LOG_FILE fi diff --git a/bin/unix/timer.sh b/bin/unix/timer.sh index b4f48c5..b7f941e 100755 --- a/bin/unix/timer.sh +++ b/bin/unix/timer.sh @@ -8,6 +8,8 @@ SIGNAL=${1:-SIGTERM} COMMAND_START="$2" COMMAND_EXIT="$3" +[ -n "$COLOR" ] && echo -en "\e[${COLOR}m" + # If SIGNAL is received, switch to next display trap 'next_display' "$SIGNAL" # Use SIGTSTP (Ctrl-Z in most of the cases) to stop/restart timer -- cgit v1.2.3-70-g09d2