timewarrior: tons of reconfiguration
This commit is contained in:
parent
6334ae5030
commit
7bbcef2314
9 changed files with 74 additions and 127 deletions
4
asmara/.config/task/host
Normal file
4
asmara/.config/task/host
Normal file
|
@ -0,0 +1,4 @@
|
|||
sync.server.url=https://taskwarrior-sync.snaile.de
|
||||
sync.server.client_id=64a3e71a-9a52-40ce-8f9e-b5bae7d1fe70
|
||||
sync.server.encryption_secret=asmara
|
||||
recurrence=off
|
28
common/.config/task/common
Normal file
28
common/.config/task/common
Normal file
|
@ -0,0 +1,28 @@
|
|||
data.location=~/.local/share/tasks
|
||||
hooks.location=~/.config/task/hooks
|
||||
weekstart=Monday
|
||||
|
||||
uda.taskwarrior-tui.background_process=task sync
|
||||
uda.taskwarrior-tui.background_process_period=15
|
||||
|
||||
# inbox
|
||||
context.inbox.read=+inbox
|
||||
context.inbox.write=+inbox
|
||||
urgency.user.tag.inbox.coefficient=15.0
|
||||
report.inbox.columns = id,description
|
||||
report.inbox.description = Inbox
|
||||
report.inbox.filter = status:pending limit:page (+in)
|
||||
report.inbox.labels = ID,Description
|
||||
|
||||
# private
|
||||
context.private.read=+@private
|
||||
context.private.write=+@private
|
||||
uda.taskwarrior-tui.shortcuts.1=~/.local/libexec/task/private
|
||||
|
||||
# work
|
||||
context.work.read=+@work
|
||||
work.work.write=+@work
|
||||
uda.taskwarrior-tui.shortcuts.2=~/.local/libexec/task/work
|
||||
|
||||
include /usr/share/doc/task/rc/dark-16.theme
|
||||
include /usr/share/doc/task/rc/holidays.de-DE.rc
|
|
@ -1,110 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Copyright 2016 - 2021, 2023, Gothenburg Bit Factory
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
# https://www.opensource.org/licenses/mit-license.php
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Hook should extract all the following for use as Timewarrior tags:
|
||||
# UUID
|
||||
# Project
|
||||
# Tags
|
||||
# Description
|
||||
# UDAs
|
||||
|
||||
try:
|
||||
input_stream = sys.stdin.buffer
|
||||
except AttributeError:
|
||||
input_stream = sys.stdin
|
||||
|
||||
|
||||
def extract_tags_from(json_obj):
|
||||
# Extract attributes for use as tags.
|
||||
tags = [json_obj['description']]
|
||||
|
||||
if 'project' in json_obj:
|
||||
tags.append(json_obj['project'])
|
||||
|
||||
if 'tags' in json_obj:
|
||||
if type(json_obj['tags']) is str:
|
||||
# Usage of tasklib (e.g. in taskpirate) converts the tag list into a string
|
||||
# If this is the case, convert it back into a list first
|
||||
# See https://github.com/tbabej/taskpirate/issues/11
|
||||
tags.extend(json_obj['tags'].split(','))
|
||||
else:
|
||||
tags.extend(json_obj['tags'])
|
||||
|
||||
return tags
|
||||
|
||||
|
||||
def extract_annotation_from(json_obj):
|
||||
|
||||
if 'annotations' not in json_obj:
|
||||
return '\'\''
|
||||
|
||||
return json_obj['annotations'][0]['description']
|
||||
|
||||
|
||||
def main(old, new):
|
||||
|
||||
start_or_stop = ''
|
||||
|
||||
# Started task.
|
||||
if 'start' in new and 'start' not in old:
|
||||
start_or_stop = 'start'
|
||||
|
||||
# Stopped task.
|
||||
elif ('start' not in new or 'end' in new) and 'start' in old:
|
||||
start_or_stop = 'stop'
|
||||
|
||||
if start_or_stop:
|
||||
tags = extract_tags_from(new)
|
||||
|
||||
subprocess.call(['timew', start_or_stop] + tags + [':yes'])
|
||||
|
||||
# Modifications to task other than start/stop
|
||||
elif 'start' in new and 'start' in old:
|
||||
old_tags = extract_tags_from(old)
|
||||
new_tags = extract_tags_from(new)
|
||||
|
||||
if old_tags != new_tags:
|
||||
subprocess.call(['timew', 'untag', '@1'] + old_tags + [':yes'])
|
||||
subprocess.call(['timew', 'tag', '@1'] + new_tags + [':yes'])
|
||||
|
||||
old_annotation = extract_annotation_from(old)
|
||||
new_annotation = extract_annotation_from(new)
|
||||
|
||||
if old_annotation != new_annotation:
|
||||
subprocess.call(['timew', 'annotate', '@1', new_annotation])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
old = json.loads(input_stream.readline().decode("utf-8", errors="replace"))
|
||||
new = json.loads(input_stream.readline().decode("utf-8", errors="replace"))
|
||||
print(json.dumps(new))
|
||||
main(old, new)
|
|
@ -1,16 +1,5 @@
|
|||
data.location=~/Public/tasks
|
||||
hooks.location=~/.config/task/hooks
|
||||
nag=Back to work wageslave!
|
||||
undo.style=diff
|
||||
weekstart=Monday
|
||||
include ~/.config/task/common
|
||||
include ~/.config/task/host
|
||||
|
||||
include /usr/share/doc/task/rc/dark-16.theme
|
||||
include /usr/share/doc/task/rc/holidays.de-DE.rc
|
||||
|
||||
context.tralios.read=+tralios +work project:misc
|
||||
context.tralios.write=+tralios +work project:misc
|
||||
|
||||
context.sfterm.read=+schneiderfilz +work project:terminal
|
||||
context.sfterm.write=+schneiderfilz +work project:terminal
|
||||
|
||||
context=tralios
|
||||
# this file should be locally ignored in git to prevent context changes from creating diffs
|
||||
news.version=3.1.0
|
||||
|
|
23
common/.local/libexec/cron/tw_sync
Executable file
23
common/.local/libexec/cron/tw_sync
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
|
||||
task sync
|
||||
|
||||
# [ -z "$CALDAV_USERNAME" ] || [ -z "$CALDAV_PASSWD" ] || [ -z "$CALDAV_URL" ] && {
|
||||
# echo "Failed caldav sync, CALDAV_USERNAME, CALDAV_PASSWD or CALDAV_URL unset."
|
||||
# exit 0
|
||||
# }
|
||||
#
|
||||
# which tw_caldav_sync >/dev/null 2>&1 || {
|
||||
# echo "Failed caldav sync, tw_caldav_sync binary not found."
|
||||
# echo
|
||||
# echo "https://github.com/bergercookie/syncall/blob/master/docs/readme-tw-caldav.md#installation"
|
||||
# exit 0
|
||||
# }
|
||||
#
|
||||
# tw_caldav_sync --days "${CALDAV_SYNC_DAYS:-1}" --verbose \
|
||||
# --caldav-url "$CALDAV_URL" \
|
||||
# --caldav-calendar "$CALDAV_CALENDAR" \
|
||||
# >"${XDG_DATA_HOME}/tw_sync.log" || {
|
||||
# echo "Failed caldav sync, tw_caldav_sync returned non-zero status code."
|
||||
# exit 0
|
||||
# }
|
3
common/.local/libexec/task/private
Executable file
3
common/.local/libexec/task/private
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
task "$1" modify -in -@work +@private
|
3
common/.local/libexec/task/work
Executable file
3
common/.local/libexec/task/work
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
task "$1" modify -in -@private +@work
|
|
@ -1,4 +1,7 @@
|
|||
#!/bin/sh
|
||||
# shellcheck disable=SC2155,SC1091
|
||||
|
||||
export PATH="$HOME/.local/libexec/cron:$PATH"
|
||||
|
||||
export XDG_DESKTOP_DIR="$HOME/Desktop"
|
||||
export XDG_DOCUMENTS_DIR="$HOME/Documents"
|
||||
|
@ -12,10 +15,15 @@ export XDG_CONFIG_HOME="$HOME/.config"
|
|||
export XDG_DATA_HOME="$HOME/.local/share"
|
||||
export XDG_CACHE_HOME="$HOME/.cache"
|
||||
export XDG_STATE_HOME="$HOME/.local/state"
|
||||
export PATH="$HOME/.local/libexec/cron:$PATH"
|
||||
|
||||
. "$XDG_STATE_HOME/dbus"
|
||||
export DBUS_SESSION_BUS_ADDRESS
|
||||
|
||||
export DISPLAY=:0
|
||||
export TERMCMD=st
|
||||
|
||||
# caldav_raw=$(rbw get "Nextcloud Snailed" --raw)
|
||||
# export CALDAV_CALENDAR=Tasks
|
||||
# export CALDAV_USERNAME="$(echo "$caldav_raw" | jq -r .data.username)"
|
||||
# export CALDAV_PASSWD="$(echo "$caldav_raw" | jq -r .data.password)"
|
||||
# export CALDAV_URL="https://$(echo "$caldav_raw" | jq -r 'first(.data.uris[] | select(.match_type == 1)).uri')/remote.php/dav"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../Public/time
|
Loading…
Add table
Reference in a new issue