feat(tray): make most basic version work
BIN
electron/assets/icons/indicator/running-anim-d/0.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/0@2x.png
Normal file
|
After Width: | Height: | Size: 638 B |
BIN
electron/assets/icons/indicator/running-anim-d/1.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/10.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/10@2x.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/11.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/11@2x.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/12.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/12@2x.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/13.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/13@2x.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/14.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/14@2x.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/15.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/15@2x.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/1@2x.png
Normal file
|
After Width: | Height: | Size: 694 B |
BIN
electron/assets/icons/indicator/running-anim-d/2.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/2@2x.png
Normal file
|
After Width: | Height: | Size: 740 B |
BIN
electron/assets/icons/indicator/running-anim-d/3.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/3@2x.png
Normal file
|
After Width: | Height: | Size: 821 B |
BIN
electron/assets/icons/indicator/running-anim-d/4.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/4@2x.png
Normal file
|
After Width: | Height: | Size: 850 B |
BIN
electron/assets/icons/indicator/running-anim-d/5.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/5@2x.png
Normal file
|
After Width: | Height: | Size: 862 B |
BIN
electron/assets/icons/indicator/running-anim-d/6.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/6@2x.png
Normal file
|
After Width: | Height: | Size: 924 B |
BIN
electron/assets/icons/indicator/running-anim-d/7.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/7@2x.png
Normal file
|
After Width: | Height: | Size: 981 B |
BIN
electron/assets/icons/indicator/running-anim-d/8.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/8@2x.png
Normal file
|
After Width: | Height: | Size: 983 B |
BIN
electron/assets/icons/indicator/running-anim-d/9.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
electron/assets/icons/indicator/running-anim-d/9@2x.png
Normal file
|
After Width: | Height: | Size: 1,009 B |
BIN
electron/assets/icons/indicator/running-anim-l/0.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/0@2x.png
Normal file
|
After Width: | Height: | Size: 577 B |
BIN
electron/assets/icons/indicator/running-anim-l/1.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/10.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/10@2x.png
Normal file
|
After Width: | Height: | Size: 975 B |
BIN
electron/assets/icons/indicator/running-anim-l/11.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/11@2x.png
Normal file
|
After Width: | Height: | Size: 995 B |
BIN
electron/assets/icons/indicator/running-anim-l/12.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/12@2x.png
Normal file
|
After Width: | Height: | Size: 1,008 B |
BIN
electron/assets/icons/indicator/running-anim-l/13.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/13@2x.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/14.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/14@2x.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/15.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/15@2x.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/1@2x.png
Normal file
|
After Width: | Height: | Size: 629 B |
BIN
electron/assets/icons/indicator/running-anim-l/2.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/2@2x.png
Normal file
|
After Width: | Height: | Size: 680 B |
BIN
electron/assets/icons/indicator/running-anim-l/3.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/3@2x.png
Normal file
|
After Width: | Height: | Size: 749 B |
BIN
electron/assets/icons/indicator/running-anim-l/4.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/4@2x.png
Normal file
|
After Width: | Height: | Size: 801 B |
BIN
electron/assets/icons/indicator/running-anim-l/5.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/5@2x.png
Normal file
|
After Width: | Height: | Size: 824 B |
BIN
electron/assets/icons/indicator/running-anim-l/6.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/6@2x.png
Normal file
|
After Width: | Height: | Size: 880 B |
BIN
electron/assets/icons/indicator/running-anim-l/7.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/7@2x.png
Normal file
|
After Width: | Height: | Size: 920 B |
BIN
electron/assets/icons/indicator/running-anim-l/8.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/8@2x.png
Normal file
|
After Width: | Height: | Size: 925 B |
BIN
electron/assets/icons/indicator/running-anim-l/9.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
electron/assets/icons/indicator/running-anim-l/9@2x.png
Normal file
|
After Width: | Height: | Size: 952 B |
BIN
electron/assets/icons/indicator/stopped-d-@2x.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
electron/assets/icons/indicator/stopped-d.png
Normal file
|
After Width: | Height: | Size: 812 B |
BIN
electron/assets/icons/indicator/stopped-l-@2x.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
electron/assets/icons/indicator/stopped-l.png
Normal file
|
After Width: | Height: | Size: 758 B |
|
|
@ -1,14 +1,12 @@
|
|||
import { App, ipcMain, Menu, nativeTheme, Tray } from 'electron';
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
// const dbus = require('./dbus');
|
||||
import { errorHandler } from './error-handler';
|
||||
import { IPC } from './ipc-events.const';
|
||||
|
||||
const GNOME_SHELL_EXT_MIN_VERSION = 2;
|
||||
|
||||
let tray;
|
||||
let isIndicatorRunning = false;
|
||||
let isGnomeShellExtensionRunning = false;
|
||||
let DIR: string;
|
||||
|
||||
const isGnomeShellExtensionRunning = false;
|
||||
|
||||
export const initIndicator = ({
|
||||
IS_LINUX,
|
||||
|
|
@ -27,68 +25,25 @@ export const initIndicator = ({
|
|||
app: App;
|
||||
ICONS_FOLDER: string;
|
||||
}) => {
|
||||
|
||||
const isGnomeShellExtensionInstalled = isGnomeShellInstalled(IS_LINUX, IS_GNOME);
|
||||
DIR = ICONS_FOLDER + 'indicator/';
|
||||
|
||||
initAppListeners(app);
|
||||
initListeners(isGnomeShellExtensionInstalled);
|
||||
initListeners();
|
||||
|
||||
// if we have the gnome shell extension installed set up bus
|
||||
if (IS_GNOME && isGnomeShellExtensionInstalled) {
|
||||
// TODO
|
||||
// dbus.init({
|
||||
// quitApp,
|
||||
// showApp,
|
||||
// });
|
||||
isGnomeShellExtensionRunning = true;
|
||||
return;
|
||||
} else if (IS_GNOME) {
|
||||
// don't start anything on GNOME as the indicator might not be visible and
|
||||
// the quiting behaviour confusing
|
||||
return;
|
||||
} else {
|
||||
// otherwise create a regular tray icon
|
||||
// switch tray icon based on
|
||||
const trayIcoFile = nativeTheme.shouldUseDarkColors
|
||||
? 'tray-ico-d.png'
|
||||
: 'tray-ico-l.png';
|
||||
const suf = nativeTheme.shouldUseDarkColors
|
||||
? '-d.png'
|
||||
: '-l.png';
|
||||
tray = new Tray(DIR + `stopped${suf}`);
|
||||
tray.setContextMenu(createContextMenu(showApp, quitApp));
|
||||
|
||||
tray = new Tray(ICONS_FOLDER + trayIcoFile);
|
||||
|
||||
tray.setContextMenu(createContextMenu(showApp, quitApp));
|
||||
|
||||
tray.on('click', () => {
|
||||
showApp();
|
||||
});
|
||||
isIndicatorRunning = true;
|
||||
return tray;
|
||||
}
|
||||
tray.on('click', () => {
|
||||
showApp();
|
||||
});
|
||||
isIndicatorRunning = true;
|
||||
return tray;
|
||||
// }
|
||||
};
|
||||
|
||||
function isGnomeShellInstalled(IS_LINUX, IS_GNOME) {
|
||||
// check if shell extension is installed
|
||||
let isGnomeShellExtInstalled = false;
|
||||
if (IS_LINUX && IS_GNOME) {
|
||||
// tslint:disable-next-line
|
||||
const LINUX_HOME_DIR = process.env['HOME'];
|
||||
const EXTENSION_PATH = LINUX_HOME_DIR + '/.local/share/gnome-shell/extensions/indicator@johannes.super-productivity.com';
|
||||
|
||||
if (existsSync(EXTENSION_PATH)) {
|
||||
const metaData = readFileSync(EXTENSION_PATH + '/metadata.json').toString();
|
||||
const version = JSON.parse(metaData).version;
|
||||
if (version >= GNOME_SHELL_EXT_MIN_VERSION) {
|
||||
isGnomeShellExtInstalled = true;
|
||||
} else {
|
||||
errorHandler('Indicator: Outdated version '
|
||||
+ version
|
||||
+ ' of Gnome Shell Extension installed. Please install at least version '
|
||||
+ GNOME_SHELL_EXT_MIN_VERSION + '.');
|
||||
}
|
||||
}
|
||||
}
|
||||
return isGnomeShellExtInstalled;
|
||||
}
|
||||
|
||||
function initAppListeners(app) {
|
||||
if (tray) {
|
||||
app.on('before-quit', () => {
|
||||
|
|
@ -99,7 +54,7 @@ function initAppListeners(app) {
|
|||
}
|
||||
}
|
||||
|
||||
function initListeners(isGnomeShellExtInstalled) {
|
||||
function initListeners() {
|
||||
ipcMain.on(IPC.CURRENT_TASK_UPDATED, (ev, params) => {
|
||||
const currentTask = params.current;
|
||||
// const lastActiveTaskTask = params.lastActiveTask;
|
||||
|
|
@ -109,25 +64,26 @@ function initListeners(isGnomeShellExtInstalled) {
|
|||
if (currentTask) {
|
||||
msg = createIndicatorStr(currentTask);
|
||||
}
|
||||
console.log(currentTask);
|
||||
|
||||
// if (isGnomeShellExtInstalled) {
|
||||
// // gnome indicator handling
|
||||
// if (currentTask && currentTask.title) {
|
||||
// dbus.setTask(currentTask.id, msg);
|
||||
// } else if (!currentTask && lastActiveTaskTask && !lastActiveTaskTask.isDone) {
|
||||
// const msg = createIndicatorStr(lastActiveTaskTask);
|
||||
// dbus.setTask('PAUSED', msg);
|
||||
// } else {
|
||||
// dbus.setTask('NONE', 'NONE');
|
||||
// }
|
||||
// } else
|
||||
//
|
||||
if (tray) {
|
||||
// tray handling
|
||||
if (currentTask && currentTask.title) {
|
||||
const suf = nativeTheme.shouldUseDarkColors
|
||||
? '-d'
|
||||
: '-l';
|
||||
const progress = currentTask.timeSpent / currentTask.timeEstimate;
|
||||
const f = Math.min(Math.round(progress * 15), 15);
|
||||
const t = DIR + `running-anim${suf}/${f || 0}@2x.png`;
|
||||
|
||||
tray.setTitle(msg);
|
||||
tray.setImage(t);
|
||||
} else {
|
||||
tray.setTitle('');
|
||||
const suf = nativeTheme.shouldUseDarkColors
|
||||
? '-d.png'
|
||||
: '-l.png';
|
||||
tray.setImage(DIR + `stopped${suf}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ export class TaskElectronEffects {
|
|||
taskChangeElectron$: any = this._actions$.pipe(
|
||||
ofType(
|
||||
TaskActionTypes.SetCurrentTask,
|
||||
TaskActionTypes.UnsetCurrentTask,
|
||||
TaskActionTypes.AddTimeSpent,
|
||||
),
|
||||
withLatestFrom(this._store$.pipe(select(selectCurrentTask))),
|
||||
tap(([action, current]) => {
|
||||
|
|
|
|||