Add some configs from generic Ubuntu

This commit is contained in:
2020-05-11 05:16:27 -04:00
parent f32c1048d1
commit 754f64f135
16037 changed files with 205635 additions and 137 deletions

View File

@@ -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>

View File

@@ -0,0 +1,82 @@
#!/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
}

View File

@@ -0,0 +1,167 @@
#!/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"
shell_version=$(gnome-shell --version | cut -d " " -f 3)
get_workspace_cmd="global.display.get_active_workspace_index()"
[[ $shell_version < "3.29" ]] &&
get_workspace_cmd="global.screen.get_active_workspace_index()"
# =====================================================================
# @@@ 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 \
"$get_workspace_cmd"
)"
# 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

View File

@@ -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 microseconds -->
<method name="get_time">
<arg name="time" type="u" direction="out"/>
</method>
</interface>
</node>

View File

@@ -0,0 +1,49 @@
<!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>
<!--
The return value is a single string where each tracked task is
delimited by the string '___timepp___'. (The dbus api is wonky and
that's all I could come up with to make it usable with bash...)
For example, the two tasks: "(B) asf" and "(A) asdf asdf"
will be returned as:
"(A) asdf asdf___timepp___(B) asf___timepp___"
-->
<method name="get_tracked_tasks">
<arg type="s" direction="out"/>
</method>
<!-- The projects are returned in a similar fashion to tasks. -->
<method name="get_tracked_projects">
<arg type="s" direction="out"/>
</method>
<signal name="started_tracking">
<arg name="tracked_task" type="s"/>
</signal>
<signal name="stopped_tracking">
<arg name="untracked_task" type="s"/>
</signal>
</interface>
</node>

View File

@@ -0,0 +1,29 @@
<!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">
<!--
Starts the timer with the default preset.
The default preset's time and msg can also be updated.
If @time == 0, then default preset's time is not updated.
If @msg == "null", then default preset's msg is not updated.
-->
<method name="start_from_default_preset">
<arg name="time" type="u" direction="in"/> <!-- seconds -->
<arg name="msg" type="s" direction="in"/>
</method>
<method name="stop"/>
<method name="toggle_timer"/>
<method name="reset"/>
<method name="show_fullscreen"/>
<signal name="timer_expired"/>
</interface>
</node>