83 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			83 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/bash
 | 
						|
 | 
						|
pomodoro_monitor () {
 | 
						|
    local signal
 | 
						|
    local -a msg
 | 
						|
 | 
						|
    gdbus monitor              \
 | 
						|
        --session              \
 | 
						|
        --dest org.gnome.Shell \
 | 
						|
        --object-path /timepp/zagortenay333/Pomodoro |
 | 
						|
    while read -r -a msg; do
 | 
						|
        signal=${msg[1]} signal=${signal##*.}
 | 
						|
 | 
						|
        case "$signal" in
 | 
						|
            "POMO")        echo "$signal";;
 | 
						|
            "STOPPED")     echo "$signal";;
 | 
						|
            "LONG_BREAK")  echo "$signal";;
 | 
						|
            "SHORT_BREAK") echo "$signal";;
 | 
						|
        esac
 | 
						|
    done
 | 
						|
}
 | 
						|
 | 
						|
# Examples:
 | 
						|
# timer_start
 | 
						|
# timer_start 60
 | 
						|
# timer_start 30 "get to the chopaaaaaaaaaaa"
 | 
						|
timer_start () {
 | 
						|
    local time="${1:-0}"
 | 
						|
    local msg="${2:-'null'}"
 | 
						|
 | 
						|
    >/dev/null gdbus call                         \
 | 
						|
        --session                                 \
 | 
						|
        --dest org.gnome.Shell                    \
 | 
						|
        --object-path /timepp/zagortenay333/Timer \
 | 
						|
        --method timepp.zagortenay333.Timer.start_from_default_preset "$time" "$msg"
 | 
						|
}
 | 
						|
 | 
						|
get_tracked_tasks () {
 | 
						|
    local res=$(
 | 
						|
        gdbus call                                \
 | 
						|
        --session                                 \
 | 
						|
        --dest org.gnome.Shell                    \
 | 
						|
        --object-path /timepp/zagortenay333/TimeTracker \
 | 
						|
        --method timepp.zagortenay333.TimeTracker.get_tracked_tasks
 | 
						|
    )
 | 
						|
 | 
						|
    echo "$res"
 | 
						|
}
 | 
						|
 | 
						|
get_tracked_projects () {
 | 
						|
    local res=$(
 | 
						|
        gdbus call                                \
 | 
						|
        --session                                 \
 | 
						|
        --dest org.gnome.Shell                    \
 | 
						|
        --object-path /timepp/zagortenay333/TimeTracker \
 | 
						|
        --method timepp.zagortenay333.TimeTracker.get_tracked_projects
 | 
						|
    )
 | 
						|
 | 
						|
    echo "$res"
 | 
						|
}
 | 
						|
 | 
						|
tracker_monitor () {
 | 
						|
    local task # the task string
 | 
						|
 | 
						|
    local sig
 | 
						|
    local msg
 | 
						|
    local -a arr
 | 
						|
 | 
						|
    gdbus monitor --session --dest org.gnome.Shell \
 | 
						|
        --object-path /timepp/zagortenay333/TimeTracker |
 | 
						|
    while read -r msg; do
 | 
						|
        read -r -a arr <<< $(echo $msg)
 | 
						|
        sig=${arr[1]} sig=${sig##*.}
 | 
						|
 | 
						|
        arr[0]='' arr[1]='' task="${arr[@]}"
 | 
						|
 | 
						|
        case "$sig" in
 | 
						|
            "started_tracking") notify-send "started:" "$task";;
 | 
						|
            "stopped_tracking") notify-send "stopped:" "$task";;
 | 
						|
        esac
 | 
						|
    done
 | 
						|
}
 |