Skip to content

Commit ab66726

Browse files
committed
Squash add single commands can be disabled v16
1 parent 9d8bb36 commit ab66726

18 files changed

+54
-199
lines changed

README.md

+4-176
Original file line numberDiff line numberDiff line change
@@ -1,187 +1,15 @@
1+
# **Executor - Gnome Shell Extension**
12
![Maintenance](https://img.shields.io/maintenance/yes/2021)
23
![GitHub release (latest by date)](https://img.shields.io/github/v/release/raujonas/executor)
34
![GitHub Release Date](https://img.shields.io/github/release-date/raujonas/executor)
4-
![GitHub commits since latest release (by date)](https://img.shields.io/github/commits-since/raujonas/executor/latest)
5-
![GitHub last commit](https://img.shields.io/github/last-commit/raujonas/executor)
65
![GitHub Repo stars](https://img.shields.io/github/stars/raujonas/executor?style=social)
76

8-
# **Executor - Gnome Shell Extension**
9-
<img src="resources/icons/icon.png" alt="result" width="70">
10-
117
Execute multiple shell commands periodically with separate intervals and display the output in gnome top bar.
128

13-
<img src="docs/result.png" alt="result" width="967">
14-
15-
<br/><br/>
16-
17-
# **Installation**
18-
19-
## **One click installation**
9+
<img src="resources/icons/icon.png" alt="result" width="70">
2010

2111
[<img src="https://raw.githubusercontent.com/andyholmes/gnome-shell-extensions-badge/master/get-it-on-ego.svg?sanitize=true" alt="Get it on GNOME Extensions" height="100" width="220">](https://extensions.gnome.org/extension/2932/executor/)
2212

13+
<img src="docs/result.png" alt="result" width="967">
2314

24-
25-
## **Manual installation**
26-
27-
- Download the file `[email protected]` <a href="https://github.com/raujonas/executor/releases/latest">from the latest release</a> and extract the content to `~/.local/share/gnome-shell/extensions/[email protected]`.
28-
29-
- OR checkout the repo to `~/.local/share/gnome-shell/extensions/[email protected]`.
30-
```
31-
git clone https://github.com/raujonas/executor.git ~/.local/share/gnome-shell/extensions/[email protected]/
32-
```
33-
With both options you have to restart gnome shell afterwards (`Alt + F2` and then enter `r`).
34-
35-
<br/><br/>
36-
37-
# **Configuration**
38-
39-
## **Basic**
40-
41-
The commands and the interval for each command can be set for each location (left, center, right) separately in the settings view.
42-
43-
<img src="docs/settings.png" alt="settings" width="500">
44-
45-
<br/><br/>
46-
47-
## **Use of custom css**
48-
49-
It is possible to use custom css to style the output of your commands dynamically. There are two ways to do this:
50-
- **Preferred option**: Create the file `~/.config/[email protected]/custom.css` and add your custom css there. This file will be imported into the extension. **This way your custom css will NOT be overwritten by extension updates**. You can use the following commands to create the file:
51-
52-
```console
53-
mkdir /home/$USER/.config/[email protected]
54-
55-
touch /home/$USER/.config/[email protected]/custom.css
56-
```
57-
- **Non durable option**: You can add your custom css in `~/.local/share/gnome-shell/extensions/[email protected]/custom.css`. **Your custom css will be overwritten by extension updates in this case**. Make sure to save it somewhere before updating.
58-
59-
Example `custom.css` file:
60-
61-
```css
62-
.red {
63-
color: red;
64-
}
65-
66-
.yellow {
67-
color: yellow
68-
}
69-
70-
.green {
71-
color: rgb(107, 179, 0);
72-
}
73-
74-
.huge-font {
75-
font: 20px "Comic Sans";
76-
}
77-
78-
.italic {
79-
font: 17px "Arial";
80-
font-style: italic;
81-
}
82-
```
83-
84-
**Note**: After making changes in your css you have to restart your shell (`Alt + F2` and then enter `r`).
85-
86-
**Usage**: To use the css classes dynamically in your commands, you can add it with the following syntax to your output: **`<executor.css.red>`**. This will add the specified css class to your output, in this case `red`.
87-
88-
**Example**: The following command queries the current timestamp. If the output is a round number it should have the color red, if not then green.
89-
90-
```console
91-
date +%s | awk '{if ($1 % 2 == 0) {print $1"<executor.css.red>"} else { print $1"<executor.css.green>"} }'
92-
```
93-
94-
The output is either one of the following depending on the timestamp:
95-
96-
<img src="docs/custom-css-red.png" alt="settings">
97-
98-
<img src="docs/custom-css-green.png" alt="settings">
99-
100-
You can also combine multiple css classes:
101-
102-
<img src="docs/custom-css-multiple.png" alt="settings" width="700">
103-
104-
<br/><br/>
105-
106-
## **Use of markup**
107-
108-
**Usage**: To use markup there's another setting **`<executor.markup.true>`** which has to be included somewhere in the output to activate markup.
109-
110-
**Example**: The following command is an example for using markup with different colors and some italic text, all inside one command. You can find other attributes like `font_family` or `size` [here](https://developer.gnome.org/pygtk/stable/pango-markup-language.html).
111-
112-
```
113-
echo "<executor.markup.true> <span foreground='blue'>Blue text</span> is <i>cool</i>! <span foreground='red'>Red text</span> is cool too"
114-
```
115-
This produces the following output:
116-
117-
<img src="docs/markup.png" alt="settings">
118-
119-
**Note**: Due to a [bug](https://gitlab.gnome.org/GNOME/mutter/-/issues/1324) in ClutterText there is an empty space in front of the first `<span>` tag required
120-
121-
<br/><br/>
122-
123-
## **Combine css and markup**
124-
125-
Combination of css and markup is also possible. In this case the setting for markup **`<executor.markup.true>`** must be located after all css settings. Here is an example:
126-
127-
```
128-
echo " <span font_family='monospace' foreground='blue'>Blue text</span> is <i>cool</i>! <span foreground='red'>Red text</span><executor.css.green><executor.markup.true> is cool too"
129-
```
130-
131-
This produces the following output:
132-
133-
<img src="docs/css-and-markup.png" alt="settings">
134-
135-
<br/><br/>
136-
137-
## **More complex scripts**
138-
139-
If you want to execute more complex scripts it might be helpful to store them outside of the extension and create the final output there.
140-
141-
[Here](https://github.com/raujonas/executor/issues/31#issue-902528380) is a very good example of how you can achieve this. With this solution it is also possible to create a rotating output of multiple different commands.
142-
143-
<br/><br/>
144-
145-
# **Export and import settings**
146-
147-
If you want to export and import all settings at once you can use dconf.
148-
149-
Export: `dconf dump /org/gnome/shell/extensions/executor/ > executor-settings.dconf`
150-
151-
Import: `dconf load /org/gnome/shell/extensions/executor/ < executor-settings.dconf`
152-
153-
<br/><br/>
154-
155-
# **Use cases**
156-
Let me know what your use cases are and I will add them here.
157-
158-
I for example use this extension for hardware monitoring:
159-
<img src="docs/use-case-1.png" alt="settings" width="500">
160-
161-
<br/><br/>
162-
163-
# **Debugging**
164-
165-
If you have no output or other issues you can have a look into the log:
166-
```console
167-
journalctl /usr/bin/gnome-shell -f
168-
```
169-
170-
<br/><br/>
171-
172-
# **Development**
173-
174-
Please feel free to contribute and suggest ideas or report bugs!
175-
176-
<br/><br/>
177-
178-
### **Compile settings schema**
179-
`glib-compile-schemas ./schemas`
180-
### **Update example.pot**
181-
`xgettext --from-code=UTF-8 --output=po/example.pot *.js`
182-
183-
<br/><br/>
184-
185-
# **Translations**
186-
187-
You can add translation for the language of your choice by editing the example.pot with a program like Poedit. Then you can submit your *.po and *.mo file inside the po/ folder.
15+
## Documentation: [here](https://raujonas.github.io/executor/)

docs/combined.png

-44.3 KB
Binary file not shown.

docs/css-and-markup.png

-2.69 KB
Binary file not shown.

docs/custom-css-green.png

-2.89 KB
Binary file not shown.

docs/custom-css-multiple.png

-11 KB
Binary file not shown.

docs/custom-css-red.png

-2.8 KB
Binary file not shown.

docs/markup.png

-2.97 KB
Binary file not shown.

docs/settings.png

-32.7 KB
Binary file not shown.

docs/use-case-1.png

-4.88 KB
Binary file not shown.

extension.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,12 @@ function checkCommands(location, json) {
191191
if (location.commandsSettings.commands.length > 0) {
192192

193193
location.commandsSettings.commands.forEach(function (command, index) {
194-
if (!executeQueue.some(c => c.uuid === command.uuid)) {
195-
command.locationName = location.name;
196-
command.index = index;
197-
executeQueue.push(command);
194+
if (command.isActive || command.isActive == null) {
195+
if (!executeQueue.some(c => c.uuid === command.uuid)) {
196+
command.locationName = location.name;
197+
command.index = index;
198+
executeQueue.push(command);
199+
}
198200
}
199201
}, this);
200202

44 Bytes
Binary file not shown.

metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"40"
1010
],
1111
"url": "https://github.com/raujonas/executor",
12-
"version": 15
12+
"version": 16
1313
}

po/de.mo

44 Bytes
Binary file not shown.

po/de.po

+9-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2021-08-07 21:09+0200\n"
11-
"PO-Revision-Date: 2021-08-07 21:09+0200\n"
10+
"POT-Creation-Date: 2021-08-11 21:43+0200\n"
11+
"PO-Revision-Date: 2021-08-11 21:43+0200\n"
1212
"Last-Translator: \n"
1313
"Language-Team: \n"
1414
"Language: de\n"
@@ -66,15 +66,19 @@ msgstr "Klick auf Output in Statusleiste aktiv:"
6666
msgid "General"
6767
msgstr "Allgemein"
6868

69-
#: prefs.js:231
69+
#: prefs.js:221
70+
msgid "Command active"
71+
msgstr "Befehl aktiv"
72+
73+
#: prefs.js:242
7074
msgid "Move command up"
7175
msgstr "Befehl nach oben bewegen"
7276

73-
#: prefs.js:235
77+
#: prefs.js:246
7478
msgid "Move command down"
7579
msgstr "Befehl nach unten bewegen"
7680

77-
#: prefs.js:239
81+
#: prefs.js:250
7882
msgid "Remove command"
7983
msgstr "Befehl entfernen"
8084

po/example.pot

+8-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2021-08-07 21:09+0200\n"
11+
"POT-Creation-Date: 2021-08-11 21:43+0200\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -65,14 +65,18 @@ msgstr ""
6565
msgid "General"
6666
msgstr ""
6767

68-
#: prefs.js:231
68+
#: prefs.js:221
69+
msgid "Command active"
70+
msgstr ""
71+
72+
#: prefs.js:242
6973
msgid "Move command up"
7074
msgstr ""
7175

72-
#: prefs.js:235
76+
#: prefs.js:246
7377
msgid "Move command down"
7478
msgstr ""
7579

76-
#: prefs.js:239
80+
#: prefs.js:250
7781
msgid "Remove command"
7882
msgstr ""

prefs.js

+23-6
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,21 @@ function prepareRow(c, index) {
214214
}
215215

216216
let row = new Gtk.ListBoxRow({ visible: true });
217-
let command = new Gtk.Entry({ visible: true, hexpand: true, margin_end: 10 });
218-
command.set_text(c.command);
219217
let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL, visible: true });
220218
row[addRow](hbox);
219+
let isActiveButton = new Gtk.CheckButton({
220+
visible: true, margin_end: 10,
221+
tooltip_text: _('Command active')
222+
});
223+
if (c.isActive || c.isActive == null) {
224+
isActiveButton.set_active(true);
225+
}
226+
isActiveButton.connect("toggled", () => {
227+
isActiveButton.set_active(isActiveButton.get_active());
228+
});
229+
hbox[add](isActiveButton);
230+
let command = new Gtk.Entry({ visible: true, hexpand: true, margin_end: 10 });
231+
command.set_text(c.command);
221232
hbox[add](command);
222233
let interval = new Gtk.SpinButton({
223234
adjustment: new Gtk.Adjustment({ lower: 1, upper: 86400, step_increment: 1 }),
@@ -227,7 +238,7 @@ function prepareRow(c, index) {
227238
hbox[add](interval);
228239

229240
let upButton = new Gtk.Button({
230-
visible: true, margin_end: 2,
241+
visible: true, margin_end: 4,
231242
tooltip_text: _('Move command up')
232243
});
233244
let downButton = new Gtk.Button({
@@ -311,17 +322,23 @@ function saveCommands() {
311322
}
312323
}
313324
for (let i = 0; i < count; i++) {
325+
let isActive;
314326
let command;
315327
let interval;
316328
if (shellVersion < 40) {
317-
command = this.listBox[position].get_row_at_index(i).get_child().get_children()[0].get_text();
318-
interval = this.listBox[position].get_row_at_index(i).get_child().get_children()[1].get_value();
329+
isActive = this.listBox[position].get_row_at_index(i).get_child().get_children()[0].get_active();
330+
command = this.listBox[position].get_row_at_index(i).get_child().get_children()[1].get_text();
331+
interval = this.listBox[position].get_row_at_index(i).get_child().get_children()[2].get_value();
319332
} else {
320333
let entry = this.listBox[position].get_row_at_index(i).get_child().get_first_child();
334+
isActive = entry.get_active();
335+
entry = entry.get_next_sibling();
321336
command = entry.get_text();
322-
interval = entry.get_next_sibling().get_value();
337+
entry = entry.get_next_sibling();
338+
interval = entry.get_value();
323339
}
324340
this.commandsArray[position].push({
341+
"isActive": isActive,
325342
"command": command,
326343
"interval": interval,
327344
"uuid": this.createUUID()

schemas/gschemas.compiled

48 Bytes
Binary file not shown.

schemas/org.gnome.shell.extensions.executor.gschema.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<default>2</default>
99
</key>
1010
<key name="left-commands-json" type="s">
11-
<default>'{"commands":[{"command":"echo Executor works!","interval":5,"uuid":"5db62c34-ece2-432e-9373-b4ba93f65483"}]}'</default>
11+
<default>'{"commands":[{"isActive":true,"command":"echo Executor works!","interval":5,"uuid":"5db62c34-ece2-432e-9373-b4ba93f65483"}]}'</default>
1212
</key>
1313
<key name="center-active" type="b">
1414
<default>true</default>
@@ -17,7 +17,7 @@
1717
<default>2</default>
1818
</key>
1919
<key name="center-commands-json" type="s">
20-
<default>'{"commands":[{"command":"echo Executor works!","interval":5,"uuid":"7ade000c-d6fc-4f44-9d05-a6693726a76c"}]}'</default>
20+
<default>'{"commands":[{"isActive":true,"command":"echo Executor works!","interval":5,"uuid":"7ade000c-d6fc-4f44-9d05-a6693726a76c"}]}'</default>
2121
</key>
2222
<key name="right-active" type="b">
2323
<default>true</default>
@@ -26,7 +26,7 @@
2626
<default>2</default>
2727
</key>
2828
<key name="right-commands-json" type="s">
29-
<default>'{"commands":[{"command":"echo Executor works!","interval":5,"uuid":"3a38985c-128b-4533-80c3-d79f1d2940bd"}]}'</default>
29+
<default>'{"commands":[{"isActive":true,"command":"echo Executor works!","interval":5,"uuid":"3a38985c-128b-4533-80c3-d79f1d2940bd"}]}'</default>
3030
</key>
3131
<key name="location" type="i">
3232
<default>0</default>

0 commit comments

Comments
 (0)