Permalink
Browse files

Added global key binding for toggling timer. <Ctrl><Alt>P is the way.

  • Loading branch information...
1 parent 286a249 commit 0d241f26c57ee113e3f02635e1107bc177bfce3b @codito codito committed Jun 3, 2011
Showing with 20 additions and 9 deletions.
  1. +5 −2 README.md
  2. +15 −7 pomodoro@arun.codito.in/extension.js
View
@@ -4,16 +4,19 @@
More on pomodoro technique [here](http://www.pomodorotechnique.com).
+# Dependencies
+- Requires [LibKeybinder3](https://github.com/engla/keybinder/tree/keybinder-3.0) for global key bindings
+
# Installation
- Copy the files in *src* to *~/.local/share/gnome-shell/extensions/pomodoro@arun.codito.in* directory
- Press *Alt + F2*, and *r* in command to restart gnome-shell
-- Click on the panel item to toggle the timer state
+- Click on the panel item to toggle the timer state, or press "<Ctrl><Alt>P"
# Bugs
I can be reached at arun at codito dot in.
# Todo
-- Add global key handlers to start/stop timer
- Timer should stop when system is locked
- Add dialog box to show up for 5 minute rest durations
- Integrate timer to Getting Things Gnome task list
+- Add config file support
@@ -1,6 +1,7 @@
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const St = imports.gi.St;
+const Keybinder = imports.gi.Keybinder;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
@@ -10,6 +11,7 @@ const Gettext = imports.gettext.domain('gnome-shell');
const _ = Gettext.gettext;
let _pomodoroInit = false;
+let _keyToggleTimer = "<Ctrl><Alt>P";
function Indicator() {
this._init.apply(this, arguments);
@@ -35,11 +37,8 @@ Indicator.prototype = {
this.menu.addMenuItem(widget);
// Register keybindings to toggle
- //let shellwm = global.window_manager;
- //shellwm.takeover_keybinding('something_new');
- //shellwm.connect('keybinding::something_new', function () {
- //Main.runDialog.open();
- //});
+ Keybinder.init();
+ Keybinder.bind(_keyToggleTimer, Lang.bind(this, this._keyHandler), null);
// Bind to system events - like lock or away
@@ -48,7 +47,10 @@ Indicator.prototype = {
},
_toggleTimerState: function(item) {
- this._stopTimer = item.state;
+ if (item != null) {
+ this._stopTimer = item.state;
+ }
+
if (this._stopTimer == false) {
this._stopTimer = true;
this._timer.set_text("[" + this._sessionCount + "] --:--");
@@ -77,10 +79,16 @@ Indicator.prototype = {
}
return false;
+ },
+
+ _keyHandler: function(keystring, data) {
+ if (keystring == _keyToggleTimer) {
+ this._toggleTimerState(null);
+ }
}
};
-// Put your extension initialization code here
+// Extension initialization code
function main() {
if (!_pomodoroInit) {
Main.StatusIconDispatcher.STANDARD_TRAY_ICON_IMPLEMENTATIONS['pomodoro'] = 'pomodoro';

0 comments on commit 0d241f2

Please sign in to comment.