-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add translations * New preferences window * New about window * Right-click menu
- Loading branch information
Showing
27 changed files
with
722 additions
and
648 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 |
---|---|---|
@@ -1,26 +1,56 @@ | ||
#!/usr/bin/make -f | ||
|
||
.PHONY : build clean install uninstall | ||
.DEFAULT_GOAL := help | ||
.PHONY : build clean install uninstall open-prefs spawn-gnome-shell translations | ||
.DEFAULT_GOAL := build | ||
|
||
UUID = [email protected] | ||
DIST_ARCHIVE = $(UUID).shell-extension.zip | ||
LOCAL = $(HOME)/.local/share/gnome-shell/extensions | ||
|
||
js_sources = $(shell find src -maxdepth 1 -type f -name '*.js') | ||
all_sources = $(shell find src -type f) | ||
|
||
build: clean | ||
js_sources = $(shell cd src && find . -maxdepth 1 -type f -name '*.js') | ||
|
||
translations_sources = src/panelMenuButton.js src/prefs.js | ||
translations_sources += $(shell find src/resources/ui -maxdepth 1 -type f -name '*.ui') | ||
translations = $(shell find src/po -maxdepth 1 -type f -name '*.po') | ||
|
||
|
||
build: dist/$(DIST_ARCHIVE) | ||
|
||
dist: | ||
mkdir -p dist/ | ||
|
||
dist/$(DIST_ARCHIVE): dist $(all_sources) | ||
gnome-extensions pack -f src/ \ | ||
$(addprefix --extra-source=../, $(js_sources)) \ | ||
$(addprefix --extra-source=, $(js_sources)) \ | ||
--extra-source=./dataProviders \ | ||
--extra-source=./resources \ | ||
--extra-source=../assets \ | ||
--extra-source=../LICENSE \ | ||
--podir=./po \ | ||
-o dist/ | ||
|
||
|
||
src/po/%.po: src/po/messages.pot | ||
msgmerge --update $@ src/po/messages.pot | ||
|
||
src/po/messages.pot: $(translations_sources) | ||
touch src/po/messages.pot && \ | ||
xgettext \ | ||
--package-name gnome-runcat-extension \ | ||
--package-version 20 \ | ||
--from-code=UTF-8 \ | ||
--output=src/po/messages.pot \ | ||
$^ | ||
|
||
translations: src/po/messages.pot $(translations) | ||
|
||
clean: | ||
rm -rf dist | ||
|
||
install: uninstall build | ||
gnome-extensions install dist/$(UUID).shell-extension.zip --force | ||
gnome-extensions install dist/$(DIST_ARCHIVE) --force | ||
gnome-extensions enable $(UUID) || true | ||
echo "You need to restart GNOME Shell to apply changes" | ||
|
||
|
@@ -31,8 +61,8 @@ uninstall: | |
open-prefs: | ||
gnome-extensions prefs $(UUID) | ||
|
||
spawn-gnome-shell: install | ||
env MUTTER_DEBUG_DUMMY_MODE_SPECS=1280x720 \ | ||
spawn-gnome-shell: | ||
env MUTTER_DEBUG_DUMMY_MODE_SPECS=1600x800 \ | ||
MUTTER_DEBUG_DUMMY_MONITOR_SCALES=1 \ | ||
dbus-run-session -- gnome-shell --nested --wayland | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<img height="165" src="assets/se.kolesnikov.runcat.svg" alt="RunCat for GNOME Shell Logo" align="right" /> | ||
<img height="165" src="src/resources/se.kolesnikov.runcat.svg" alt="RunCat for GNOME Shell Logo" align="right" /> | ||
|
||
# RunCat for GNOME Shell | ||
|
||
|
@@ -15,7 +15,7 @@ This is the recommended method for installation, as it doesn't require the build | |
|
||
[<img src="assets/get-it-on-ego.png" height="100">](https://extensions.gnome.org/extension/2986/runcat/) | ||
|
||
### Manual installation | ||
### Manual installation | ||
|
||
#### From source code | ||
If you want to install the extension from sources, clone [the RunCat repository](https://github.com/win0err/gnome-runcat), navigate to the cloned directory and run: | ||
|
@@ -24,23 +24,24 @@ $ make install | |
``` | ||
|
||
#### Release ZIP-archive | ||
If you want to install the extension from release zip-archive, | ||
download `[email protected]` from [the releases section](https://github.com/win0err/gnome-runcat/releases) and run: | ||
If you want to install the extension from release zip-archive, | ||
download `[email protected].shell-extension.zip` from [the releases section](https://github.com/win0err/gnome-runcat/releases) and run: | ||
```bash | ||
$ gnome-extensions install path/to/[email protected] --force | ||
$ gnome-extensions install path/to/[email protected].shell-extension.zip --force | ||
``` | ||
|
||
#### After installation: | ||
1. Restart the GNOME Shell: | ||
1. Restart the GNOME Shell: | ||
- <kbd>ALT</kbd>+<kbd>F2</kbd> to open the command prompt, and enter <kbd>r</kbd> to restart the GNOME Shell; | ||
- or Log Out, then Log In, if GNOME Shell won't restart; | ||
2. Enable the extension: | ||
2. Enable the extension: | ||
- Open GNOME Tweaks → Extensions → RunCat → On; | ||
- or Run in terminal: `gnome-extensions enable [email protected]`. | ||
|
||
|
||
### Manage RunCat preferences | ||
- Open GNOME Tweaks → Extensions → RunCat → ⚙️; | ||
- Right-click on the extension button on the top bar → Settings; | ||
- or Open GNOME Tweaks → Extensions → RunCat → ⚙️; | ||
- or Open [RunCat on GNOME Extensions portal](https://extensions.gnome.org/extension/2986/runcat/) → ⚙️; | ||
- or Manage directly in `dconf`: `dconf list /org/gnome/shell/extensions/runcat/`. | ||
|
||
|
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,21 @@ | ||
/* eslint-disable no-var, no-unused-vars */ | ||
|
||
var SCHEMA_PATH = 'org.gnome.shell.extensions.runcat'; | ||
var LOG_ERROR_PREFIX = 'RuncatExtensionError'; | ||
|
||
const CHARACTER_AND_PERCENTAGE = 0; | ||
const PERCENTAGE_ONLY = 1; | ||
const CHARACTER_ONLY = 2; | ||
|
||
var PanelMenuButtonVisibility = { | ||
[CHARACTER_AND_PERCENTAGE]: { character: true, percentage: true }, | ||
[PERCENTAGE_ONLY]: { character: false, percentage: true }, | ||
[CHARACTER_ONLY]: { character: true, percentage: false }, | ||
}; | ||
|
||
var Settings = { | ||
IDLE_THRESHOLD: 'idle-threshold', | ||
DISPLAYING_ITEMS: 'displaying-items', | ||
}; | ||
|
||
var SYSTEM_MONITOR_COMMAND = 'gnome-system-monitor -r'; |
This file was deleted.
Oops, something went wrong.
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,59 @@ | ||
const { Gio } = imports.gi; | ||
const Extension = imports.misc.extensionUtils.getCurrentExtension(); | ||
|
||
const { readFile } = Extension.imports.utils; | ||
|
||
// eslint-disable-next-line func-names, no-unused-vars, no-var | ||
var createGenerator = async function* () { | ||
const procStatFile = Gio.File.new_for_path('/proc/stat'); | ||
|
||
let prevActive = 0; | ||
let prevTotal = 0; | ||
|
||
while (true) { | ||
// eslint-disable-next-line no-await-in-loop | ||
const procStatContents = await readFile(procStatFile); | ||
|
||
const cpuInfo = procStatContents | ||
.split('\n')[0].trim() | ||
.split(/[\s]+/) | ||
.map(n => parseInt(n, 10)); | ||
|
||
const [ | ||
, // eslint-disable-line | ||
user, | ||
nice, | ||
system, | ||
idle, | ||
iowait, | ||
irq, // eslint-disable-line | ||
softirq, | ||
steal, | ||
guest, // eslint-disable-line | ||
] = cpuInfo; | ||
|
||
const active = user + system + nice + softirq + steal; | ||
const total = user + system + nice + softirq + steal + idle + iowait; | ||
|
||
// eslint-disable-next-line object-curly-newline | ||
const data = JSON.stringify({ total, active, prevTotal, prevActive }); | ||
|
||
let utilization = 100 * ((active - prevActive) / (total - prevTotal)); | ||
if (Number.isNaN(utilization) || !Number.isFinite(utilization)) { | ||
log(`cpu utilization is ${utilization}, data: ${data}`); | ||
|
||
utilization = 0; | ||
} | ||
|
||
if (utilization > 100) { | ||
log(`cpu utilization is ${utilization}, data: ${data}`); | ||
|
||
utilization = 100; | ||
} | ||
|
||
prevActive = active; | ||
prevTotal = total; | ||
|
||
yield utilization; | ||
} | ||
}; |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,13 +2,12 @@ | |
"name": "RunCat", | ||
"description": "The cat tells you the CPU usage by running speed", | ||
"uuid": "[email protected]", | ||
"gettext-domain": "[email protected]", | ||
"shell-version": [ | ||
"3.38", | ||
"40", | ||
"41", | ||
"42", | ||
"43" | ||
], | ||
"session-modes": ["user"], | ||
"url": "https://github.com/win0err/gnome-runcat", | ||
"version": 19 | ||
"version": 20 | ||
} |
Oops, something went wrong.