forked from zagortenay333/cronomix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6a6ece
commit 0d983ff
Showing
27 changed files
with
1,099 additions
and
817 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE node PUBLIC | ||
'-//freedesktop//DTD D-BUS Object Introspection 1.0//EN' | ||
'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'> | ||
|
||
<node> | ||
<interface name="timepp.zagortenay333.Pomodoro"> | ||
|
||
<method name="start_pomo"> | ||
<arg name="pomo" type="d"/> <!-- seconds --> | ||
</method> | ||
|
||
<method name="start_new_pomo"/> | ||
<method name="stop"/> | ||
<method name="take_break"/> | ||
<method name="timer_toggle"/> | ||
<method name="show_fullscreen"/> | ||
<method name="clear_pomo_counter"/> | ||
|
||
<method name="set_phase_durations"> | ||
<arg name="pomo" type="s"/> <!-- seconds --> | ||
<arg name="short_break" type="s"/> <!-- seconds --> | ||
<arg name="long_break" type="s"/> <!-- seconds --> | ||
<arg name="break_rate" type="s"/> <!-- long break every n pomos --> | ||
</method> | ||
|
||
<!-- state is one of: 'POMO', 'STOPPED', 'LONG_BREAK', 'SHORT_BREAK' --> | ||
<signal name="pomo_state_changed"> | ||
<arg name="state" type="s"/> | ||
</signal> | ||
|
||
</interface> | ||
</node> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
|
||
# ===================================================================== | ||
# Templates for monitoring a signal and calling a method | ||
# ===================================================================== | ||
|
||
|
||
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 | ||
} | ||
|
||
timer_start () { | ||
local time="$1" | ||
|
||
>/dev/null gdbus call \ | ||
--session \ | ||
--dest org.gnome.Shell \ | ||
--object-path /timepp/zagortenay333/Timer \ | ||
--method timepp.zagortenay333.Timer.start "$time" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
|
||
# ===================================================================== | ||
# This script is used to control the time-tracker of the Time++ gnome | ||
# shell extension: | ||
# https://github.com/zagortenay333/timepp__gnome | ||
# | ||
# Once executed, the script will listen for when the workspace change | ||
# and do something. | ||
# | ||
# The tracker is controled by supplying string arguments. | ||
# An arg string is of the form: | ||
# "["default" ]tracker_id n1[, n2, n3,...]" | ||
# | ||
# If the string starts with the "default" keyword then: | ||
# - the given tracker_id is gonna be the default id | ||
# - no workspace numbers need to provided | ||
# | ||
# The tracker_id is either: | ||
# - the string "stop" | ||
# - a tracker_id specified in Time++ using the the "tracker_id:string" | ||
# todo.txt extension. (See README of Time++.) | ||
# | ||
# The n1, n2, ... numbers correspond to workspace numbers. They are | ||
# 0-indexed. | ||
# | ||
# Examples: | ||
# | ||
# 1) tracker_control "stop 0" "default id1 2 3" "id2 1 4" | ||
# Means: | ||
# - If on workspace number 0 , stop the tracker. | ||
# - If on workspace number 2 or 3, start tracking tasks with id "id1". | ||
# - If on workspace number 1 or 4, start tracking tasks with id "id2". | ||
# - If on any other workspace , start tracking tasks with id "id1". | ||
# | ||
# 2) tracker_control "id1 2 3" | ||
# Means: | ||
# - If on workspace number 2 or 3, start tracking tasks with id "id1". | ||
# - If on any other workspace , stop tracking. | ||
# | ||
# 3) tracker_control "default id1" | ||
# Means: | ||
# - Always track tasks with id "id1". | ||
# | ||
# 4) tracker_control | ||
# Means: | ||
# - Stop tracking. | ||
# ===================================================================== | ||
|
||
|
||
# ===================================================================== | ||
# @@@ Constants | ||
# ===================================================================== | ||
declare -A id_workspace_map | ||
|
||
current_workspace=0 | ||
|
||
current_id=0 | ||
|
||
default_id="stop" | ||
|
||
|
||
|
||
# ===================================================================== | ||
# @@@ Funcs | ||
# ===================================================================== | ||
stop_tracking () { | ||
>/dev/null gdbus call \ | ||
--session \ | ||
--dest org.gnome.Shell \ | ||
--object-path /timepp/zagortenay333/TimeTracker \ | ||
--method timepp.zagortenay333.TimeTracker.stop_all_tracking | ||
} | ||
|
||
start_tracking () { | ||
local id=$1 | ||
|
||
stop_tracking | ||
|
||
>/dev/null gdbus call \ | ||
--session \ | ||
--dest org.gnome.Shell \ | ||
--object-path /timepp/zagortenay333/TimeTracker \ | ||
--method timepp.zagortenay333.TimeTracker.start_tracking_by_id "$id" | ||
} | ||
|
||
on_workspace_changed () { | ||
local found_id=$default_id | ||
local it | ||
local workspace | ||
|
||
for it in "${!id_workspace_map[@]}"; do | ||
for workspace in ${id_workspace_map[$it]}; do | ||
[[ $workspace == "$current_workspace" ]] && found_id=$it && break 1 | ||
done | ||
done | ||
|
||
[[ $found_id == "$current_id" ]] && return | ||
|
||
if [[ $found_id == "stop" ]]; then | ||
stop_tracking | ||
else | ||
start_tracking "$found_id" | ||
fi | ||
|
||
current_id=$found_id | ||
} | ||
|
||
check_workspace () { | ||
local workspace | ||
|
||
read -r -a workspace <<< "$( | ||
gdbus call \ | ||
--session \ | ||
--dest org.gnome.Shell \ | ||
--object-path /org/gnome/Shell \ | ||
--method org.gnome.Shell.Eval \ | ||
"global.screen.get_active_workspace_index()" | ||
)" | ||
|
||
# gdbus will return a string of the form "('bool', 'n')". | ||
# We need to extract n only. | ||
workspace=${workspace[1]} | ||
workspace=${workspace:1: -2} | ||
|
||
if [[ $workspace != "$current_workspace" ]]; then | ||
current_workspace=$workspace | ||
on_workspace_changed | ||
fi | ||
} | ||
|
||
|
||
|
||
# ===================================================================== | ||
# @@@ Parse args | ||
# ===================================================================== | ||
[[ $# == 0 ]] && stop_tracking && exit | ||
|
||
for it in "$@"; do | ||
read -r -a it <<< "$it" | ||
|
||
case ${it[0]} in | ||
"default") | ||
default_id=${it[1]} | ||
id_workspace_map[${it[1]}]="${it[*]:2}" | ||
;; | ||
*) | ||
id_workspace_map[${it[0]}]="${it[*]:1}" | ||
esac | ||
done | ||
|
||
|
||
|
||
# ===================================================================== | ||
# @@@ Mainloop | ||
# ===================================================================== | ||
trap "stop_tracking" INT TERM EXIT | ||
|
||
while true; do | ||
check_workspace | ||
sleep 1 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE node PUBLIC | ||
'-//freedesktop//DTD D-BUS Object Introspection 1.0//EN' | ||
'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'> | ||
|
||
<node> | ||
<interface name="timepp.zagortenay333.Stopwatch"> | ||
|
||
<method name="start"/> | ||
<method name="stop"/> | ||
<method name="reset"/> | ||
<method name="lap"/> | ||
<method name="show_fullscreen"/> | ||
|
||
<!-- time is returned in miliseconds --> | ||
<method name="get_time"> | ||
<arg name="time" type="u" direction="out"/> | ||
</method> | ||
|
||
</interface> | ||
</node> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE node PUBLIC | ||
'-//freedesktop//DTD D-BUS Object Introspection 1.0//EN' | ||
'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'> | ||
|
||
<node> | ||
<interface name="timepp.zagortenay333.TimeTracker"> | ||
|
||
<method name="stop_all_tracking"/> | ||
|
||
<!-- | ||
- The argument is the tracker id specified using the | ||
- 'tracker_id:string' todo.txt extension. | ||
--> | ||
<method name="stop_tracking_by_id"> | ||
<arg name="tracker_id" type="s" direction="in"/> | ||
</method> | ||
|
||
<method name="start_tracking_by_id"> | ||
<arg name="tracker_id" type="s" direction="in"/> | ||
</method> | ||
|
||
</interface> | ||
</node> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE node PUBLIC | ||
'-//freedesktop//DTD D-BUS Object Introspection 1.0//EN' | ||
'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'> | ||
|
||
<node> | ||
<interface name="timepp.zagortenay333.Timer"> | ||
|
||
<method name="start"> | ||
<arg name="time" type="u" direction="in"/> <!-- in seconds --> | ||
</method> | ||
|
||
<method name="stop"/> | ||
<method name="toggle_timer"/> | ||
<method name="reset"/> | ||
<method name="show_fullscreen"/> | ||
|
||
<method name="set_notif_msg"> | ||
<arg name="msg" type="s" direction="in"/> | ||
</method> | ||
|
||
<signal name="timer_expired"/> | ||
|
||
</interface> | ||
</node> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.