Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard shortcuts and installation step for linux users #196

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ Marinara is open source software and is built by volunteers from around the worl
- [Maite Clausell](https://github.com/mcmtradu): Catalan translation
- [Craig Loftus](https://github.com/craigloftus): Autostart timers
- [Mathias Mikkelsen](https://github.com/Fysikeren): Danish translation
- [Abrar Shariar](https://github.com/abrarShariar): Japanese translation
- [Giovanni Pessiva](https://github.com/giovannipessiva): Italian translation
- [TomG777](https://github.com/TomG777): Dutch translation
- [João Pedro Sconetto](https://github.com/sconetto): Portuguese (Brazil) translation
- [Ridho Pratama](https://github.com/ridho9): Indonesian translation
- [Ivan Nesic](https://github.com/fatkaratekid): Serbian translation
- [Duc Trinh](https://github.com/dmtri): Vietnamese translation
- [Markus Deibel](https://github.com/msdeibel): German translation
- [Pyrox](https://github.com/Pyr0x1): Italian translation
- [Pyrox](https://github.com/Pyr0x1): Italian translation
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ It also uses [jq](https://stedolan.github.io/jq/) to manipulate the `manifest.js

brew install jq

For Linux run:

sudo apt-get install jq
sudo apt-get install ruby-full

Once installed you can package a release by running:

make package
Expand Down
14 changes: 14 additions & 0 deletions src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ class Controller
this.timer.start();
}
});

chrome.commands.onCommand.addListener((command) => {
if(command === 'toggle-start-pause'){
if (this.timer.isRunning) {
this.timer.pause();
} else if (this.timer.isPaused) {
this.timer.resume();
} else {
this.timer.start();
}
} else if (command === 'reset-timer'){
this.timer.start(Phase.Focus);
}
});
}

async showOptionsPage(hash) {
Expand Down
16 changes: 16 additions & 0 deletions src/background/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ class BackgroundClient extends MessageClient
static showSettings() {
return this.request('showSettings', arguments);
}

static skipBreak() {
return this.request('skipBreak', arguments);
}

static skipFocus() {
return this.request('skipFocus', arguments);
}
}

class BackgroundServer extends MessageServer
Expand Down Expand Up @@ -137,6 +145,14 @@ class BackgroundServer extends MessageServer
return await this.controller.showOptionsPage('#settings');
}

async skipBreak() {
this.controller.startFocus();
}

async skipFocus() {
this.controller.startShortBreak();
}

_normalize(phase) {
let duration = phase.duration.trim();
if (!duration) {
Expand Down
9 changes: 8 additions & 1 deletion src/expire/expire.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ body {
background: #2b2;
color: #fff;
}
.button.skip-break {
background: #ee2223;
}

.button.skip-focus {
background: #2b2;
}
.button.focus {
background: #e22;
color: #fff;
Expand All @@ -70,7 +77,7 @@ body {
box-shadow: none;
transition-delay: 0s;
}
.button:not(.focus):not(.break):not(.short-break):not(.long-break) {
.button:not(.focus):not(.break):not(.short-break):not(.long-break):not(.skip-focus):not(.skip-break) {
display: none;
}
#start-session {
Expand Down
6 changes: 6 additions & 0 deletions src/expire/expire.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ <h1><span id="session-title"></span></h1>
<button id="start-session" class="button">
<span id="session-action"></span>
</button>
<button id="skip-break" class="button skip-break">
<span id="skip-break-action"></span>
</button>
<button id="skip-focus" class="button skip-focus">
<span id="skip-focus-action"></span>
</button>
<div class="pomodoros-today">
<p id="pomodoros"></p>
<p data-t="completed_today"></p>
Expand Down
13 changes: 13 additions & 0 deletions src/expire/expire.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ chrome.runtime.onMessage.addListener(function onMessage(request, sender, respond
title.innerText = request.title;
action.innerText = request.action;

if(request.phase === "focus"){
document.getElementById('skip-break').style.display = 'none';
document.getElementById('skip-focus-action').innerText = 'Skip Focus';
} else {
document.getElementById('skip-focus').style.display = 'none';
document.getElementById('skip-break-action').innerText = 'Skip Break';
}

let message = request.messages.filter(m => m && m.trim() !== '').join(' &mdash; ');
let p = document.createElement('p');
p.innerHTML = message;
Expand All @@ -24,7 +32,12 @@ chrome.runtime.onMessage.addListener(function onMessage(request, sender, respond

async function load() {
let start = document.getElementById('start-session');
let skipFocus = document.getElementById('skip-focus');
let skipBreak = document.getElementById('skip-break');

start.onclick = () => BackgroundClient.startSession();
skipFocus.onclick = () => BackgroundClient.skipFocus();
skipBreak.onclick = () => BackgroundClient.skipBreak();

let history = document.getElementById('view-history');
history.onclick = () => {
Expand Down
16 changes: 16 additions & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@
"48": "icons/48.png",
"128": "icons/128.png"
},
"commands": {
"toggle-start-pause": {
"suggested_key": {
"default": "Ctrl+Shift+Space",
"mac": "Command+Shift+Space"
},
"description": "Toggle feature for start and pause of timer"
},
"reset-timer": {
"suggested_key": {
"default": "Ctrl+Shift+S",
"mac": "Command+Shift+S"
},
"description": "Reset timer to start focusing"
}
},
"minimum_chrome_version": "55",
"content_security_policy": "script-src 'self'; object-src 'self'"
}