@sdeck/plugin-system 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +308 -387
- package/dist/index.js.map +3 -3
- package/package.json +6 -6
- package/src/index.tsx +356 -400
package/dist/index.js
CHANGED
|
@@ -3,18 +3,19 @@
|
|
|
3
3
|
import { execFile as execFile3, spawn as spawn3 } from "child_process";
|
|
4
4
|
import { cpus as cpus2, freemem, homedir as homedir3, totalmem } from "os";
|
|
5
5
|
import { basename, join as join3 } from "path";
|
|
6
|
-
import {
|
|
7
|
-
defineAction,
|
|
8
|
-
definePlugin,
|
|
9
|
-
defineTrigger,
|
|
10
|
-
Shared as Shared2
|
|
11
|
-
} from "@sdeck/plugin";
|
|
6
|
+
import { createPlugin, Permissions, Shared as Shared2, setting } from "@sdeck/plugin";
|
|
12
7
|
import {
|
|
13
8
|
formatAccelerator,
|
|
14
9
|
iconLayer,
|
|
15
10
|
iconLook,
|
|
11
|
+
iconSize,
|
|
12
|
+
KEY,
|
|
13
|
+
meterLayer,
|
|
16
14
|
parseAccelerator as parseAccelerator2,
|
|
17
|
-
|
|
15
|
+
readable,
|
|
16
|
+
surface,
|
|
17
|
+
textLayer,
|
|
18
|
+
volumeStepLayers
|
|
18
19
|
} from "@sdeck/schema";
|
|
19
20
|
|
|
20
21
|
// src/controls.ts
|
|
@@ -769,6 +770,69 @@ function watchForeground(emit, onError) {
|
|
|
769
770
|
}
|
|
770
771
|
|
|
771
772
|
// src/index.tsx
|
|
773
|
+
var hostField = (label) => setting.text(label, {
|
|
774
|
+
default: "1.1.1.1",
|
|
775
|
+
required: true,
|
|
776
|
+
validate: (host) => isHost(host.trim()) ? undefined : "should be a name or an address, like 1.1.1.1"
|
|
777
|
+
});
|
|
778
|
+
var plugin = createPlugin({
|
|
779
|
+
id: "@sdeck/plugin-system",
|
|
780
|
+
name: "System",
|
|
781
|
+
version: "0.5.0",
|
|
782
|
+
description: "Open apps and run commands, press media keys and shortcuts, lock and sleep, take screenshots, and monitor the computer.",
|
|
783
|
+
author: "sdeck",
|
|
784
|
+
permissions: [
|
|
785
|
+
Permissions.shell,
|
|
786
|
+
Permissions.process,
|
|
787
|
+
Permissions.input,
|
|
788
|
+
Permissions.network,
|
|
789
|
+
Permissions.filesystem
|
|
790
|
+
],
|
|
791
|
+
settings: {
|
|
792
|
+
pingHost: hostField("Ping host"),
|
|
793
|
+
disks: setting.text("Disks", {
|
|
794
|
+
placeholder: process.platform === "win32" ? "C:, D:" : "/, /home",
|
|
795
|
+
description: "Comma separated. Empty means the system disk."
|
|
796
|
+
}),
|
|
797
|
+
presentMon: setting.text("PresentMon", {
|
|
798
|
+
default: "PresentMon",
|
|
799
|
+
description: "Command or full path, for the frame rate (Windows)."
|
|
800
|
+
})
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
var values = {
|
|
804
|
+
memory: plugin.state.number("memory", "Memory use", {
|
|
805
|
+
permissions: [],
|
|
806
|
+
unit: "%",
|
|
807
|
+
poll: { everyMs: 2000, read: () => Math.round(100 * (1 - freemem() / totalmem())) }
|
|
808
|
+
}),
|
|
809
|
+
memoryFree: plugin.state.number("memoryFree", "Free memory", {
|
|
810
|
+
permissions: [],
|
|
811
|
+
unit: "bytes",
|
|
812
|
+
poll: { everyMs: 2000, read: () => freemem() }
|
|
813
|
+
}),
|
|
814
|
+
processes: plugin.state.json("processes", "Running processes", {
|
|
815
|
+
permissions: [Permissions.process],
|
|
816
|
+
description: 'Lowercased names; e.g. contains(system.processes, "javaw.exe").',
|
|
817
|
+
start: (set) => processes.listen((names) => set([...names]))
|
|
818
|
+
}),
|
|
819
|
+
idle: plugin.state.number("idle", "Idle time", {
|
|
820
|
+
permissions: [Permissions.process],
|
|
821
|
+
unit: "s",
|
|
822
|
+
description: "Seconds since the last keyboard or mouse input.",
|
|
823
|
+
start: (set) => idle.listen(set)
|
|
824
|
+
}),
|
|
825
|
+
foreground: plugin.state.string("foreground", "App in front", {
|
|
826
|
+
permissions: [Permissions.process],
|
|
827
|
+
description: `The focused window's executable, lowercased ("javaw.exe"); empty when none. Profiles switch on it.`,
|
|
828
|
+
start: (set) => foreground.listen(set)
|
|
829
|
+
}),
|
|
830
|
+
online: plugin.state.boolean("online", "Online", {
|
|
831
|
+
permissions: [],
|
|
832
|
+
description: "Whether any network interface has an address.",
|
|
833
|
+
start: (set) => network.listen((addresses) => set(addresses.length > 0))
|
|
834
|
+
})
|
|
835
|
+
};
|
|
772
836
|
function openWithSystem(target) {
|
|
773
837
|
const [command, args] = process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", target]] : process.platform === "darwin" ? ["open", [target]] : ["xdg-open", [target]];
|
|
774
838
|
spawn3(command, args, {
|
|
@@ -799,66 +863,57 @@ function runShell(command, cwd, signal) {
|
|
|
799
863
|
child.once("close", (code) => done(code ?? -1));
|
|
800
864
|
});
|
|
801
865
|
}
|
|
802
|
-
var
|
|
803
|
-
var
|
|
866
|
+
var BLUE = "#60a5fa";
|
|
867
|
+
var GREEN = "#4ade80";
|
|
868
|
+
var VIOLET = "#a78bfa";
|
|
869
|
+
var ORANGE = "#fb923c";
|
|
870
|
+
var buttonLook = (icon, color, s) => iconLook({ icon: s.image || icon, color, caption: s.text, background: s.background });
|
|
871
|
+
var open = plugin.action({
|
|
804
872
|
id: "open",
|
|
805
|
-
permissions: [
|
|
873
|
+
permissions: [Permissions.process],
|
|
806
874
|
name: "Open",
|
|
807
875
|
description: "Opens a website, file, folder or app.",
|
|
808
876
|
category: "System",
|
|
809
877
|
icon: "external-link",
|
|
810
878
|
settings: {
|
|
811
|
-
target: {
|
|
812
|
-
|
|
813
|
-
label: "URL or path",
|
|
879
|
+
target: setting.text("URL or path", {
|
|
880
|
+
required: true,
|
|
814
881
|
placeholder: "https://example.com or C:\\Tools\\app.exe"
|
|
815
|
-
},
|
|
816
|
-
text: {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
placeholder: "Optional, under the icon",
|
|
820
|
-
appearance: true
|
|
821
|
-
},
|
|
822
|
-
image: { type: "image", label: "Image", appearance: true },
|
|
823
|
-
background: { type: "color", label: "Background", default: "#0969da", appearance: true }
|
|
882
|
+
}),
|
|
883
|
+
text: setting.text("Text", { placeholder: "Optional, under the icon", appearance: true }),
|
|
884
|
+
image: setting.image("Image", { appearance: true }),
|
|
885
|
+
background: setting.color("Background", { default: KEY, appearance: true })
|
|
824
886
|
},
|
|
825
887
|
run: ({ settings, plugin }) => {
|
|
826
|
-
if (!settings.target)
|
|
827
|
-
throw new Error("nothing to open");
|
|
828
888
|
plugin.log("open", settings.target);
|
|
829
889
|
openWithSystem(settings.target);
|
|
830
890
|
return { label: `Open ${settings.target}` };
|
|
831
891
|
},
|
|
832
|
-
look: (s) => buttonLook("lucide/external-link",
|
|
892
|
+
look: (s) => buttonLook("lucide/external-link", BLUE, s)
|
|
833
893
|
});
|
|
834
|
-
var command =
|
|
894
|
+
var command = plugin.action({
|
|
835
895
|
id: "command",
|
|
836
|
-
permissions: [
|
|
896
|
+
permissions: [Permissions.shell],
|
|
837
897
|
name: "Run command",
|
|
838
898
|
description: "Runs a shell command. Fails when it exits with an error; its output is the result.",
|
|
839
899
|
category: "System",
|
|
840
900
|
icon: "terminal",
|
|
841
901
|
settings: {
|
|
842
|
-
command:
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
902
|
+
command: setting.text("Command", {
|
|
903
|
+
required: true,
|
|
904
|
+
placeholder: "echo hello",
|
|
905
|
+
multiline: true
|
|
906
|
+
}),
|
|
907
|
+
cwd: setting.text("Working directory", { placeholder: "Defaults to your home folder" }),
|
|
908
|
+
undo: setting.text("Undo command", {
|
|
847
909
|
description: "Run to revert it (from the history, or a toggle's second press).",
|
|
848
910
|
multiline: true
|
|
849
|
-
},
|
|
850
|
-
text: {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
placeholder: "Optional, under the icon",
|
|
854
|
-
appearance: true
|
|
855
|
-
},
|
|
856
|
-
image: { type: "image", label: "Image", appearance: true },
|
|
857
|
-
background: { type: "color", label: "Background", default: "#24292f", appearance: true }
|
|
911
|
+
}),
|
|
912
|
+
text: setting.text("Text", { placeholder: "Optional, under the icon", appearance: true }),
|
|
913
|
+
image: setting.image("Image", { appearance: true }),
|
|
914
|
+
background: setting.color("Background", { default: KEY, appearance: true })
|
|
858
915
|
},
|
|
859
916
|
run: async ({ settings, plugin, signal }) => {
|
|
860
|
-
if (!settings.command)
|
|
861
|
-
throw new Error("no command");
|
|
862
917
|
const cwd = settings.cwd || homedir3();
|
|
863
918
|
plugin.log("run", settings.command);
|
|
864
919
|
const { code, output } = await runShell(settings.command, cwd, signal);
|
|
@@ -877,7 +932,7 @@ var command = defineAction({
|
|
|
877
932
|
}
|
|
878
933
|
};
|
|
879
934
|
},
|
|
880
|
-
look: (s) => buttonLook("lucide/terminal",
|
|
935
|
+
look: (s) => buttonLook("lucide/terminal", GREEN, s)
|
|
881
936
|
});
|
|
882
937
|
function cpuSampler() {
|
|
883
938
|
const read = () => cpus2().reduce((acc, cpu) => {
|
|
@@ -927,7 +982,7 @@ var METRICS = {
|
|
|
927
982
|
ping: { icon: "lucide/activity", text: reading("ping", " ms"), bar: undefined },
|
|
928
983
|
fps: { icon: "lucide/gauge", text: reading("fps", ""), bar: undefined }
|
|
929
984
|
};
|
|
930
|
-
var stats =
|
|
985
|
+
var stats = plugin.action({
|
|
931
986
|
id: "stats",
|
|
932
987
|
permissions: [],
|
|
933
988
|
name: "System stats",
|
|
@@ -936,106 +991,96 @@ var stats = defineAction({
|
|
|
936
991
|
icon: "activity",
|
|
937
992
|
slots: ["key", "sensor", "window"],
|
|
938
993
|
settings: {
|
|
939
|
-
show: {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
{ value: "fps", label: "Frame rate (PresentMon)" }
|
|
955
|
-
]
|
|
956
|
-
},
|
|
957
|
-
color: { type: "color", label: "Colour", default: "#58a6ff" },
|
|
958
|
-
background: { type: "color", label: "Background", default: "#0d1117" }
|
|
994
|
+
show: setting.select("Show", {
|
|
995
|
+
both: "CPU and memory",
|
|
996
|
+
cpu: "CPU",
|
|
997
|
+
core: "Busiest CPU core",
|
|
998
|
+
memory: "Memory",
|
|
999
|
+
disk: "Disk space used",
|
|
1000
|
+
network: "Network speed",
|
|
1001
|
+
ping: "Ping",
|
|
1002
|
+
gpu: "GPU load (NVIDIA)",
|
|
1003
|
+
"gpu-temp": "GPU temperature (NVIDIA)",
|
|
1004
|
+
"cpu-temp": "CPU temperature",
|
|
1005
|
+
fps: "Frame rate (PresentMon)"
|
|
1006
|
+
}),
|
|
1007
|
+
color: setting.color("Colour", { default: BLUE }),
|
|
1008
|
+
background: setting.color("Background", { default: KEY })
|
|
959
1009
|
},
|
|
960
1010
|
display: true,
|
|
961
|
-
look: (s) => {
|
|
962
|
-
const
|
|
963
|
-
id,
|
|
964
|
-
type: "bar",
|
|
965
|
-
value,
|
|
966
|
-
color: s.color,
|
|
967
|
-
track: "#30363d",
|
|
968
|
-
position: "bottom",
|
|
969
|
-
thickness: 6
|
|
970
|
-
});
|
|
1011
|
+
look: (s, slot) => {
|
|
1012
|
+
const background = surface(s.background);
|
|
971
1013
|
const row = (id, icon, value, size) => [
|
|
972
|
-
iconLayer(`${id}-icon`, icon, { color: s.color, size:
|
|
973
|
-
textLayer(id, value, {
|
|
1014
|
+
iconLayer(`${id}-icon`, icon, { color: s.color, size: 23, row: id }),
|
|
1015
|
+
textLayer(id, value, { size, row: id })
|
|
974
1016
|
];
|
|
1017
|
+
const two = (a, b) => {
|
|
1018
|
+
if (slot !== "window")
|
|
1019
|
+
return { background, layers: [...row(...a), ...row(...b)] };
|
|
1020
|
+
const half = ([id, icon, value, size], x) => [
|
|
1021
|
+
iconLayer(`${id}-icon`, icon, {
|
|
1022
|
+
color: s.color,
|
|
1023
|
+
frame: { x, y: 28, width: 11, height: 44 }
|
|
1024
|
+
}),
|
|
1025
|
+
textLayer(id, value, {
|
|
1026
|
+
size: size + 5,
|
|
1027
|
+
align: "left",
|
|
1028
|
+
frame: { x: x + 13, y: 15, width: 34, height: 70 }
|
|
1029
|
+
})
|
|
1030
|
+
];
|
|
1031
|
+
return { background, layers: [...half(a, 6), ...half(b, 54)] };
|
|
1032
|
+
};
|
|
975
1033
|
if (s.show === "both") {
|
|
976
|
-
return {
|
|
977
|
-
background: s.background,
|
|
978
|
-
layers: [
|
|
979
|
-
...row("cpu", "lucide/cpu", "{{system.cpu}}%", 18),
|
|
980
|
-
...row("memory", "lucide/memory-stick", "{{system.memory}}%", 18)
|
|
981
|
-
]
|
|
982
|
-
};
|
|
1034
|
+
return two(["cpu", "lucide/cpu", "{{system.cpu}}%", 19], ["memory", "lucide/memory-stick", "{{system.memory}}%", 19]);
|
|
983
1035
|
}
|
|
984
1036
|
if (s.show === "network") {
|
|
985
|
-
return {
|
|
986
|
-
background: s.background,
|
|
987
|
-
layers: [
|
|
988
|
-
...row("down", "lucide/arrow-down", "{{bytes(system.netDown ?? 0)}}", 13),
|
|
989
|
-
...row("up", "lucide/arrow-up", "{{bytes(system.netUp ?? 0)}}", 13)
|
|
990
|
-
]
|
|
991
|
-
};
|
|
1037
|
+
return two(["down", "lucide/arrow-down", "{{bytes(system.netDown ?? 0)}}", 13], ["up", "lucide/arrow-up", "{{bytes(system.netUp ?? 0)}}", 13]);
|
|
992
1038
|
}
|
|
993
1039
|
const metric = METRICS[s.show];
|
|
994
1040
|
const id = s.show;
|
|
1041
|
+
const line = slot === "window" ? { row: "line" } : {};
|
|
995
1042
|
return {
|
|
996
|
-
background
|
|
1043
|
+
background,
|
|
997
1044
|
layers: [
|
|
998
|
-
iconLayer(`${id}-icon`, metric.icon, {
|
|
999
|
-
|
|
1000
|
-
|
|
1045
|
+
iconLayer(`${id}-icon`, metric.icon, {
|
|
1046
|
+
color: s.color,
|
|
1047
|
+
size: slot === "window" ? 42 : 34,
|
|
1048
|
+
...line
|
|
1049
|
+
}),
|
|
1050
|
+
textLayer(id, metric.text, { size: slot === "window" ? 24 : 22, ...line }),
|
|
1051
|
+
...metric.bar ? [meterLayer(`${id}-bar`, metric.bar, { color: s.color })] : []
|
|
1001
1052
|
]
|
|
1002
1053
|
};
|
|
1003
1054
|
}
|
|
1004
1055
|
});
|
|
1005
1056
|
var MEDIA = {
|
|
1006
|
-
"play-pause": { label: "Play / Pause", icons: ["
|
|
1007
|
-
next: { label: "Next track", icons: ["
|
|
1008
|
-
previous: { label: "Previous track", icons: ["
|
|
1009
|
-
stop: { label: "Stop playback", icons: ["
|
|
1010
|
-
"volume-up": { label: "Volume up", icons: ["volume
|
|
1011
|
-
"volume-down": { label: "Volume down", icons: ["volume
|
|
1057
|
+
"play-pause": { label: "Play / Pause", icons: ["Play", "Pause"], undo: "play-pause" },
|
|
1058
|
+
next: { label: "Next track", icons: ["SkipForward"], undo: "previous" },
|
|
1059
|
+
previous: { label: "Previous track", icons: ["SkipBack"], undo: "next" },
|
|
1060
|
+
stop: { label: "Stop playback", icons: ["Stop"], undo: undefined },
|
|
1061
|
+
"volume-up": { label: "Volume up", icons: ["volume"], undo: "volume-down" },
|
|
1062
|
+
"volume-down": { label: "Volume down", icons: ["volume"], undo: "volume-up" },
|
|
1012
1063
|
mute: { label: "Mute", icons: ["volume-x"], undo: "mute" }
|
|
1013
1064
|
};
|
|
1014
|
-
var
|
|
1065
|
+
var mapValues = (from, map) => Object.fromEntries(Object.entries(from).map(([key, value]) => [key, map(value)]));
|
|
1066
|
+
var media = plugin.action({
|
|
1015
1067
|
id: "media",
|
|
1016
|
-
permissions: [
|
|
1068
|
+
permissions: [Permissions.input],
|
|
1017
1069
|
name: "Media and volume",
|
|
1018
1070
|
description: "Presses a media or volume key, as a keyboard would.",
|
|
1019
1071
|
category: "Controls",
|
|
1020
1072
|
icon: "play",
|
|
1021
1073
|
slots: ["key", "sensor"],
|
|
1022
1074
|
settings: {
|
|
1023
|
-
key:
|
|
1024
|
-
|
|
1025
|
-
label: "Key",
|
|
1026
|
-
default: "play-pause",
|
|
1027
|
-
options: Object.entries(MEDIA).map(([value, m]) => ({ value, label: m.label }))
|
|
1028
|
-
},
|
|
1029
|
-
steps: {
|
|
1030
|
-
type: "number",
|
|
1031
|
-
label: "Presses",
|
|
1075
|
+
key: setting.select("Key", mapValues(MEDIA, (m) => m.label)),
|
|
1076
|
+
steps: setting.number("Presses", {
|
|
1032
1077
|
description: "Each volume press is about 2%.",
|
|
1033
1078
|
default: 1,
|
|
1034
1079
|
min: 1,
|
|
1035
1080
|
max: 50,
|
|
1036
1081
|
visibleIf: { key: ["volume-up", "volume-down"] }
|
|
1037
|
-
},
|
|
1038
|
-
background:
|
|
1082
|
+
}),
|
|
1083
|
+
background: setting.color("Background", { default: KEY, appearance: true })
|
|
1039
1084
|
},
|
|
1040
1085
|
run: async ({ settings }) => {
|
|
1041
1086
|
const controls = await systemControls();
|
|
@@ -1049,112 +1094,113 @@ var media = defineAction({
|
|
|
1049
1094
|
const undo = MEDIA[key].undo;
|
|
1050
1095
|
return { label: MEDIA[key].label, ...undo && { undo: () => press(undo) } };
|
|
1051
1096
|
},
|
|
1052
|
-
look: (s) => {
|
|
1097
|
+
look: (s, slot) => {
|
|
1053
1098
|
const { icons } = MEDIA[s.key];
|
|
1099
|
+
if (s.key === "volume-up" || s.key === "volume-down") {
|
|
1100
|
+
const step = s.key === "volume-up" ? "plus" : "minus";
|
|
1101
|
+
const color = readable("#f4f4f5", s.background);
|
|
1102
|
+
return {
|
|
1103
|
+
background: surface(s.background),
|
|
1104
|
+
layers: volumeStepLayers(step, slot, { color })
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1054
1107
|
return {
|
|
1055
|
-
background: s.background,
|
|
1056
|
-
layers: icons.map((name, i) => iconLayer(i === 0 ? "icon" : `icon-${i + 1}`, `lucide/${name}`, {
|
|
1057
|
-
|
|
1108
|
+
background: surface(s.background),
|
|
1109
|
+
layers: icons.map((name, i) => iconLayer(i === 0 ? "icon" : `icon-${i + 1}`, /^[A-Z]/.test(name) ? `tb/TbPlayer${name}Filled` : `lucide/${name}`, {
|
|
1110
|
+
color: readable("#f4f4f5", s.background),
|
|
1111
|
+
size: icons.length === 1 ? iconSize(false) : 36,
|
|
1058
1112
|
row: "icons"
|
|
1059
1113
|
}))
|
|
1060
1114
|
};
|
|
1061
1115
|
}
|
|
1062
1116
|
});
|
|
1063
|
-
var hotkey =
|
|
1117
|
+
var hotkey = plugin.action({
|
|
1064
1118
|
id: "hotkey",
|
|
1065
|
-
permissions: [
|
|
1119
|
+
permissions: [Permissions.input],
|
|
1066
1120
|
name: "Press a shortcut",
|
|
1067
1121
|
description: "Sends a keyboard shortcut to the focused app.",
|
|
1068
1122
|
category: "Controls",
|
|
1069
1123
|
icon: "keyboard",
|
|
1070
1124
|
slots: ["key", "sensor"],
|
|
1071
1125
|
settings: {
|
|
1072
|
-
keys:
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
}
|
|
1079
|
-
background: { type: "color", label: "Background", default: "#374151", appearance: true }
|
|
1126
|
+
keys: setting.text("Shortcut", {
|
|
1127
|
+
required: true,
|
|
1128
|
+
placeholder: "ctrl+shift+m",
|
|
1129
|
+
validate: (keys) => void parseAccelerator2(keys)
|
|
1130
|
+
}),
|
|
1131
|
+
text: setting.text("Text", { placeholder: "Defaults to the shortcut", appearance: true }),
|
|
1132
|
+
background: setting.color("Background", { default: KEY, appearance: true })
|
|
1080
1133
|
},
|
|
1081
1134
|
run: async ({ settings }) => {
|
|
1082
1135
|
const accelerator = parseAccelerator2(settings.keys);
|
|
1083
1136
|
await (await systemControls()).hotkey(accelerator);
|
|
1084
1137
|
return { label: `Press ${formatAccelerator(accelerator)}` };
|
|
1085
1138
|
},
|
|
1086
|
-
look: (s) => iconLook({
|
|
1139
|
+
look: (s) => iconLook({
|
|
1140
|
+
icon: "lucide/keyboard",
|
|
1141
|
+
color: VIOLET,
|
|
1142
|
+
caption: s.text || s.keys,
|
|
1143
|
+
background: s.background
|
|
1144
|
+
})
|
|
1087
1145
|
});
|
|
1088
|
-
var type =
|
|
1146
|
+
var type = plugin.action({
|
|
1089
1147
|
id: "type",
|
|
1090
|
-
permissions: [
|
|
1148
|
+
permissions: [Permissions.input],
|
|
1091
1149
|
name: "Type text",
|
|
1092
1150
|
description: "Types text into the focused app. The text can use {{templates}}.",
|
|
1093
1151
|
category: "Controls",
|
|
1094
1152
|
icon: "text-cursor-input",
|
|
1095
1153
|
slots: ["key", "sensor"],
|
|
1096
1154
|
settings: {
|
|
1097
|
-
content:
|
|
1098
|
-
text: {
|
|
1099
|
-
|
|
1100
|
-
label: "Key text",
|
|
1101
|
-
placeholder: "Optional, under the icon",
|
|
1102
|
-
appearance: true
|
|
1103
|
-
},
|
|
1104
|
-
background: { type: "color", label: "Background", default: "#374151", appearance: true }
|
|
1155
|
+
content: setting.text("Text to type", { required: true, multiline: true }),
|
|
1156
|
+
text: setting.text("Key text", { placeholder: "Optional, under the icon", appearance: true }),
|
|
1157
|
+
background: setting.color("Background", { default: KEY, appearance: true })
|
|
1105
1158
|
},
|
|
1106
1159
|
run: async ({ settings }) => {
|
|
1107
|
-
if (!settings.content)
|
|
1108
|
-
throw new Error("nothing to type");
|
|
1109
1160
|
await (await systemControls()).type(settings.content);
|
|
1110
1161
|
return { label: `Type ${settings.content.length} character(s)` };
|
|
1111
1162
|
},
|
|
1112
|
-
look: (s) => iconLook({
|
|
1163
|
+
look: (s) => iconLook({
|
|
1164
|
+
icon: "lucide/text-cursor-input",
|
|
1165
|
+
color: VIOLET,
|
|
1166
|
+
caption: s.text,
|
|
1167
|
+
background: s.background
|
|
1168
|
+
})
|
|
1113
1169
|
});
|
|
1114
|
-
var lock =
|
|
1170
|
+
var lock = plugin.action({
|
|
1115
1171
|
id: "lock",
|
|
1116
|
-
permissions: [
|
|
1172
|
+
permissions: [Permissions.process],
|
|
1117
1173
|
name: "Lock the screen",
|
|
1118
1174
|
category: "Controls",
|
|
1119
1175
|
icon: "lock",
|
|
1120
1176
|
slots: ["key", "sensor"],
|
|
1121
1177
|
settings: {
|
|
1122
|
-
text: {
|
|
1123
|
-
|
|
1124
|
-
label: "Text",
|
|
1125
|
-
placeholder: "Optional, under the icon",
|
|
1126
|
-
appearance: true
|
|
1127
|
-
},
|
|
1128
|
-
background: { type: "color", label: "Background", default: "#7c2d12", appearance: true }
|
|
1178
|
+
text: setting.text("Text", { placeholder: "Optional, under the icon", appearance: true }),
|
|
1179
|
+
background: setting.color("Background", { default: KEY, appearance: true })
|
|
1129
1180
|
},
|
|
1130
1181
|
run: async () => {
|
|
1131
1182
|
await (await systemControls()).lock();
|
|
1132
1183
|
return { label: "Lock the screen" };
|
|
1133
1184
|
},
|
|
1134
|
-
look: (s) => iconLook({ icon: "lucide/lock", caption: s.text, background: s.background })
|
|
1185
|
+
look: (s) => iconLook({ icon: "lucide/lock", color: ORANGE, caption: s.text, background: s.background })
|
|
1135
1186
|
});
|
|
1136
|
-
var sleep =
|
|
1187
|
+
var sleep = plugin.action({
|
|
1137
1188
|
id: "sleep",
|
|
1138
|
-
permissions: [
|
|
1189
|
+
permissions: [Permissions.process],
|
|
1139
1190
|
name: "Sleep",
|
|
1140
1191
|
description: "Puts the computer to sleep.",
|
|
1141
1192
|
category: "Controls",
|
|
1142
1193
|
icon: "moon",
|
|
1143
1194
|
slots: ["key", "sensor"],
|
|
1144
1195
|
settings: {
|
|
1145
|
-
text: {
|
|
1146
|
-
|
|
1147
|
-
label: "Text",
|
|
1148
|
-
placeholder: "Optional, under the icon",
|
|
1149
|
-
appearance: true
|
|
1150
|
-
},
|
|
1151
|
-
background: { type: "color", label: "Background", default: "#1e1b4b", appearance: true }
|
|
1196
|
+
text: setting.text("Text", { placeholder: "Optional, under the icon", appearance: true }),
|
|
1197
|
+
background: setting.color("Background", { default: KEY, appearance: true })
|
|
1152
1198
|
},
|
|
1153
1199
|
run: async () => {
|
|
1154
1200
|
await (await systemControls()).sleep();
|
|
1155
1201
|
return { label: "Sleep" };
|
|
1156
1202
|
},
|
|
1157
|
-
look: (s) => iconLook({ icon: "lucide/moon", caption: s.text, background: s.background })
|
|
1203
|
+
look: (s) => iconLook({ icon: "lucide/moon", color: VIOLET, caption: s.text, background: s.background })
|
|
1158
1204
|
});
|
|
1159
1205
|
function screenshotName(at) {
|
|
1160
1206
|
const two = (n) => String(n).padStart(2, "0");
|
|
@@ -1162,37 +1208,19 @@ function screenshotName(at) {
|
|
|
1162
1208
|
const time = `${two(at.getHours())}${two(at.getMinutes())}${two(at.getSeconds())}`;
|
|
1163
1209
|
return `screenshot-${day}-${time}.png`;
|
|
1164
1210
|
}
|
|
1165
|
-
var screenshot =
|
|
1211
|
+
var screenshot = plugin.action({
|
|
1166
1212
|
id: "screenshot",
|
|
1167
|
-
permissions: [
|
|
1213
|
+
permissions: [Permissions.process, Permissions.filesystem],
|
|
1168
1214
|
name: "Screenshot",
|
|
1169
1215
|
description: "Saves the screen to a file (the result), or opens the region picker.",
|
|
1170
1216
|
category: "Controls",
|
|
1171
1217
|
icon: "camera",
|
|
1172
1218
|
slots: ["key", "sensor"],
|
|
1173
1219
|
settings: {
|
|
1174
|
-
mode: {
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
options: [
|
|
1179
|
-
{ value: "file", label: "Whole screen, to a file" },
|
|
1180
|
-
{ value: "snip", label: "A region I choose" }
|
|
1181
|
-
]
|
|
1182
|
-
},
|
|
1183
|
-
folder: {
|
|
1184
|
-
type: "text",
|
|
1185
|
-
label: "Folder",
|
|
1186
|
-
placeholder: "Pictures/sdeck",
|
|
1187
|
-
visibleIf: { mode: "file" }
|
|
1188
|
-
},
|
|
1189
|
-
text: {
|
|
1190
|
-
type: "text",
|
|
1191
|
-
label: "Text",
|
|
1192
|
-
placeholder: "Optional, under the icon",
|
|
1193
|
-
appearance: true
|
|
1194
|
-
},
|
|
1195
|
-
background: { type: "color", label: "Background", default: "#065f46", appearance: true }
|
|
1220
|
+
mode: setting.select("Capture", { file: "Whole screen, to a file", snip: "A region I choose" }),
|
|
1221
|
+
folder: setting.text("Folder", { placeholder: "Pictures/sdeck", visibleIf: { mode: "file" } }),
|
|
1222
|
+
text: setting.text("Text", { placeholder: "Optional, under the icon", appearance: true }),
|
|
1223
|
+
background: setting.color("Background", { default: KEY, appearance: true })
|
|
1196
1224
|
},
|
|
1197
1225
|
run: async ({ settings }) => {
|
|
1198
1226
|
const controls = await systemControls();
|
|
@@ -1207,26 +1235,27 @@ var screenshot = defineAction({
|
|
|
1207
1235
|
},
|
|
1208
1236
|
look: (s) => iconLook({
|
|
1209
1237
|
icon: s.mode === "snip" ? "lucide/scissors" : "lucide/camera",
|
|
1238
|
+
color: GREEN,
|
|
1210
1239
|
caption: s.text,
|
|
1211
1240
|
background: s.background
|
|
1212
1241
|
})
|
|
1213
1242
|
});
|
|
1214
|
-
var pingAction =
|
|
1243
|
+
var pingAction = plugin.action({
|
|
1215
1244
|
id: "ping",
|
|
1216
|
-
permissions: [
|
|
1245
|
+
permissions: [Permissions.network],
|
|
1217
1246
|
name: "Ping",
|
|
1218
1247
|
description: "Pings a host; the result is the round trip in ms. Fails when it does not answer.",
|
|
1219
1248
|
category: "Monitoring",
|
|
1220
1249
|
icon: "radio",
|
|
1221
1250
|
settings: {
|
|
1222
|
-
host:
|
|
1223
|
-
background:
|
|
1251
|
+
host: hostField("Host"),
|
|
1252
|
+
background: setting.color("Background", { default: KEY, appearance: true })
|
|
1224
1253
|
},
|
|
1225
1254
|
run: async ({ settings, signal }) => {
|
|
1226
1255
|
const ms = await ping(settings.host, signal);
|
|
1227
1256
|
return { result: ms, label: `Ping ${settings.host}: ${ms} ms` };
|
|
1228
1257
|
},
|
|
1229
|
-
look: (s) => iconLook({ icon: "lucide/activity", caption: s.host, background: s.background })
|
|
1258
|
+
look: (s) => iconLook({ icon: "lucide/activity", color: BLUE, caption: s.host, background: s.background })
|
|
1230
1259
|
});
|
|
1231
1260
|
var processes = new Shared2((emit) => {
|
|
1232
1261
|
let stopped = false;
|
|
@@ -1312,23 +1341,12 @@ async function disks(context) {
|
|
|
1312
1341
|
}
|
|
1313
1342
|
var throughputSource = new Shared2((emit) => watchNetwork(emit, (error) => networkError?.(error)));
|
|
1314
1343
|
var networkError;
|
|
1315
|
-
var
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
permissions: [
|
|
1321
|
-
start: (set, context) => {
|
|
1322
|
-
networkError = (error) => markUnavailable(context, "network speed", error);
|
|
1323
|
-
return throughputSource.listen((rate) => set(pick(rate)));
|
|
1324
|
-
}
|
|
1325
|
-
});
|
|
1326
|
-
var gpuState = (id, name, type, pick, unit) => ({
|
|
1327
|
-
id,
|
|
1328
|
-
name,
|
|
1329
|
-
type,
|
|
1330
|
-
...unit && { unit },
|
|
1331
|
-
permissions: ["process"],
|
|
1344
|
+
var reportNetwork = (pick) => (set, context) => {
|
|
1345
|
+
networkError = (error) => markUnavailable(context, "network speed", error);
|
|
1346
|
+
return throughputSource.listen((rate) => set(pick(rate)));
|
|
1347
|
+
};
|
|
1348
|
+
var fromGpu = (pick) => ({
|
|
1349
|
+
permissions: [Permissions.process],
|
|
1332
1350
|
poll: {
|
|
1333
1351
|
everyMs: 2000,
|
|
1334
1352
|
read: async (context) => {
|
|
@@ -1337,78 +1355,77 @@ var gpuState = (id, name, type, pick, unit) => ({
|
|
|
1337
1355
|
}
|
|
1338
1356
|
}
|
|
1339
1357
|
});
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
}
|
|
1357
|
-
})
|
|
1358
|
-
{
|
|
1359
|
-
|
|
1360
|
-
permissions: ["filesystem"],
|
|
1361
|
-
name: "Disks",
|
|
1362
|
-
type: "json",
|
|
1358
|
+
function sampled(start) {
|
|
1359
|
+
let sample;
|
|
1360
|
+
return () => {
|
|
1361
|
+
sample ??= start();
|
|
1362
|
+
return sample();
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
var monitoring = {
|
|
1366
|
+
cpu: plugin.state.number("cpu", "CPU use", {
|
|
1367
|
+
permissions: [],
|
|
1368
|
+
unit: "%",
|
|
1369
|
+
poll: { everyMs: 2000, read: sampled(cpuSampler) }
|
|
1370
|
+
}),
|
|
1371
|
+
cpuCores: plugin.state.json("cpuCores", "CPU use per core", {
|
|
1372
|
+
permissions: [],
|
|
1373
|
+
description: "system.cpuCores[0] is the first core.",
|
|
1374
|
+
poll: { everyMs: 2000, read: sampled(coreSampler) }
|
|
1375
|
+
}),
|
|
1376
|
+
disks: plugin.state.json("disks", "Disks", {
|
|
1377
|
+
permissions: [Permissions.filesystem],
|
|
1363
1378
|
description: "system.disks.c.percent, .free, .total (choose them in the plugin's settings).",
|
|
1364
1379
|
poll: { everyMs: 15000, read: disks }
|
|
1365
|
-
},
|
|
1366
|
-
{
|
|
1367
|
-
|
|
1368
|
-
permissions: ["filesystem"],
|
|
1369
|
-
name: "Disk space used",
|
|
1370
|
-
type: "number",
|
|
1380
|
+
}),
|
|
1381
|
+
disk: plugin.state.number("disk", "Disk space used", {
|
|
1382
|
+
permissions: [Permissions.filesystem],
|
|
1371
1383
|
unit: "%",
|
|
1372
1384
|
description: "The first disk in the plugin's settings.",
|
|
1373
1385
|
poll: {
|
|
1374
1386
|
everyMs: 15000,
|
|
1375
1387
|
read: async (context) => Object.values(await disks(context))[0]?.percent
|
|
1376
1388
|
}
|
|
1377
|
-
},
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1389
|
+
}),
|
|
1390
|
+
netDown: plugin.state.number("netDown", "Download speed", {
|
|
1391
|
+
permissions: [Permissions.process],
|
|
1392
|
+
unit: "B/s",
|
|
1393
|
+
start: reportNetwork((c) => c.received)
|
|
1394
|
+
}),
|
|
1395
|
+
netUp: plugin.state.number("netUp", "Upload speed", {
|
|
1396
|
+
permissions: [Permissions.process],
|
|
1397
|
+
unit: "B/s",
|
|
1398
|
+
start: reportNetwork((c) => c.sent)
|
|
1399
|
+
}),
|
|
1400
|
+
ping: plugin.state.number("ping", "Ping", {
|
|
1401
|
+
permissions: [Permissions.network],
|
|
1385
1402
|
unit: "ms",
|
|
1386
1403
|
description: "To the host in the plugin's settings.",
|
|
1387
1404
|
poll: {
|
|
1388
1405
|
everyMs: 5000,
|
|
1389
|
-
read: (context) => measured(context, "ping", () => ping(
|
|
1406
|
+
read: (context) => measured(context, "ping", () => ping(context.settings().pingHost))
|
|
1390
1407
|
}
|
|
1391
|
-
},
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1408
|
+
}),
|
|
1409
|
+
gpu: plugin.state.number("gpu", "GPU load", { unit: "%", ...fromGpu((g) => g.load) }),
|
|
1410
|
+
gpuTemp: plugin.state.number("gpuTemp", "GPU temperature", {
|
|
1411
|
+
unit: "\xB0C",
|
|
1412
|
+
...fromGpu((g) => g.temperature)
|
|
1413
|
+
}),
|
|
1414
|
+
gpuMemory: plugin.state.number("gpuMemory", "GPU memory used", {
|
|
1415
|
+
unit: "%",
|
|
1416
|
+
...fromGpu((g) => g.memory)
|
|
1417
|
+
}),
|
|
1418
|
+
gpuName: plugin.state.string("gpuName", "GPU name", fromGpu((g) => g.name)),
|
|
1419
|
+
cpuTemp: plugin.state.number("cpuTemp", "CPU temperature", {
|
|
1420
|
+
permissions: [Permissions.process],
|
|
1401
1421
|
unit: "\xB0C",
|
|
1402
1422
|
poll: {
|
|
1403
1423
|
everyMs: 5000,
|
|
1404
1424
|
read: (context) => measured(context, "CPU temperature", () => cpuTemperature())
|
|
1405
1425
|
}
|
|
1406
|
-
},
|
|
1407
|
-
{
|
|
1408
|
-
|
|
1409
|
-
permissions: ["process"],
|
|
1410
|
-
name: "Frame rate",
|
|
1411
|
-
type: "number",
|
|
1426
|
+
}),
|
|
1427
|
+
fps: plugin.state.number("fps", "Frame rate", {
|
|
1428
|
+
permissions: [Permissions.process],
|
|
1412
1429
|
description: "Of the app in front, measured by PresentMon.",
|
|
1413
1430
|
start: (set, context) => {
|
|
1414
1431
|
let front;
|
|
@@ -1418,7 +1435,7 @@ var monitoring = [
|
|
|
1418
1435
|
let stop = () => {};
|
|
1419
1436
|
const begin = () => {
|
|
1420
1437
|
stop();
|
|
1421
|
-
stop = watchFrameRate(
|
|
1438
|
+
stop = watchFrameRate(context.settings().presentMon, () => front, set, (error) => markUnavailable(context, "frame rate", error));
|
|
1422
1439
|
};
|
|
1423
1440
|
begin();
|
|
1424
1441
|
let command = context.settings().presentMon;
|
|
@@ -1435,15 +1452,14 @@ var monitoring = [
|
|
|
1435
1452
|
stopFront();
|
|
1436
1453
|
};
|
|
1437
1454
|
}
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1455
|
+
})
|
|
1456
|
+
};
|
|
1440
1457
|
var processSetting = {
|
|
1441
|
-
process: {
|
|
1442
|
-
|
|
1443
|
-
label: "Process",
|
|
1458
|
+
process: setting.text("Process", {
|
|
1459
|
+
required: true,
|
|
1444
1460
|
placeholder: "javaw.exe",
|
|
1445
1461
|
description: "The executable name, as in the task manager (case does not matter)."
|
|
1446
|
-
}
|
|
1462
|
+
})
|
|
1447
1463
|
};
|
|
1448
1464
|
function onProcess(name, want, fire) {
|
|
1449
1465
|
const target = name.trim().toLowerCase();
|
|
@@ -1459,35 +1475,36 @@ function onProcess(name, want, fire) {
|
|
|
1459
1475
|
before = now;
|
|
1460
1476
|
});
|
|
1461
1477
|
}
|
|
1462
|
-
var appOpen =
|
|
1478
|
+
var appOpen = plugin.trigger({
|
|
1463
1479
|
id: "app-open",
|
|
1464
|
-
permissions: [
|
|
1480
|
+
permissions: [Permissions.process],
|
|
1465
1481
|
name: "When an app opens",
|
|
1466
1482
|
description: "Runs when a process starts (checked every 3 s).",
|
|
1467
1483
|
settings: processSetting,
|
|
1468
1484
|
subscribe: ({ settings, fire }) => onProcess(settings.process, "started", fire)
|
|
1469
1485
|
});
|
|
1470
|
-
var appClose =
|
|
1486
|
+
var appClose = plugin.trigger({
|
|
1471
1487
|
id: "app-close",
|
|
1472
|
-
permissions: [
|
|
1488
|
+
permissions: [Permissions.process],
|
|
1473
1489
|
name: "When an app closes",
|
|
1474
1490
|
description: "Runs when a process exits (checked every 3 s).",
|
|
1475
1491
|
settings: processSetting,
|
|
1476
1492
|
subscribe: ({ settings, fire }) => onProcess(settings.process, "stopped", fire)
|
|
1477
1493
|
});
|
|
1478
|
-
var fileCreated =
|
|
1494
|
+
var fileCreated = plugin.trigger({
|
|
1479
1495
|
id: "file-created",
|
|
1480
|
-
permissions: [
|
|
1496
|
+
permissions: [Permissions.filesystem],
|
|
1481
1497
|
name: "When a file appears",
|
|
1482
1498
|
description: "Runs when a new file shows up in a folder (event.name, event.path).",
|
|
1483
1499
|
settings: {
|
|
1484
|
-
folder:
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1500
|
+
folder: setting.text("Folder", {
|
|
1501
|
+
required: true,
|
|
1502
|
+
placeholder: "C:\\Users\\me\\Downloads"
|
|
1503
|
+
}),
|
|
1504
|
+
pattern: setting.text("Name pattern", {
|
|
1488
1505
|
placeholder: "*.png",
|
|
1489
1506
|
description: "Empty means any file."
|
|
1490
|
-
}
|
|
1507
|
+
})
|
|
1491
1508
|
},
|
|
1492
1509
|
subscribe: ({ settings, fire }) => {
|
|
1493
1510
|
if (!settings.folder)
|
|
@@ -1499,7 +1516,7 @@ var fileCreated = defineTrigger({
|
|
|
1499
1516
|
});
|
|
1500
1517
|
}
|
|
1501
1518
|
});
|
|
1502
|
-
var networkChange =
|
|
1519
|
+
var networkChange = plugin.trigger({
|
|
1503
1520
|
id: "network-change",
|
|
1504
1521
|
permissions: [],
|
|
1505
1522
|
name: "When the network changes",
|
|
@@ -1517,22 +1534,14 @@ var networkChange = defineTrigger({
|
|
|
1517
1534
|
});
|
|
1518
1535
|
}
|
|
1519
1536
|
});
|
|
1520
|
-
var idleTrigger =
|
|
1537
|
+
var idleTrigger = plugin.trigger({
|
|
1521
1538
|
id: "idle",
|
|
1522
|
-
permissions: [
|
|
1539
|
+
permissions: [Permissions.process],
|
|
1523
1540
|
name: "When the computer is idle",
|
|
1524
1541
|
description: "Runs after no keyboard or mouse input for a while, or when input comes back.",
|
|
1525
1542
|
settings: {
|
|
1526
|
-
minutes:
|
|
1527
|
-
when: {
|
|
1528
|
-
type: "select",
|
|
1529
|
-
label: "Run",
|
|
1530
|
-
default: "idle",
|
|
1531
|
-
options: [
|
|
1532
|
-
{ value: "idle", label: "When it becomes idle" },
|
|
1533
|
-
{ value: "back", label: "When input comes back" }
|
|
1534
|
-
]
|
|
1535
|
-
}
|
|
1543
|
+
minutes: setting.number("Idle for (minutes)", { default: 5, min: 1, max: 600 }),
|
|
1544
|
+
when: setting.select("Run", { idle: "When it becomes idle", back: "When input comes back" })
|
|
1536
1545
|
},
|
|
1537
1546
|
subscribe: ({ settings, fire, plugin }) => {
|
|
1538
1547
|
const limit = settings.minutes * 60;
|
|
@@ -1558,14 +1567,15 @@ var idleTrigger = defineTrigger({
|
|
|
1558
1567
|
};
|
|
1559
1568
|
}
|
|
1560
1569
|
});
|
|
1561
|
-
var appFocus =
|
|
1570
|
+
var appFocus = plugin.trigger({
|
|
1562
1571
|
id: "app-focus",
|
|
1563
|
-
permissions: [
|
|
1572
|
+
permissions: [Permissions.process],
|
|
1564
1573
|
name: "When an app comes to the front",
|
|
1565
1574
|
description: "Runs when a window of this app gets focus (event.app), or of any app if empty.",
|
|
1566
1575
|
settings: {
|
|
1567
1576
|
process: {
|
|
1568
1577
|
...processSetting.process,
|
|
1578
|
+
required: false,
|
|
1569
1579
|
description: "The executable name; empty means any app."
|
|
1570
1580
|
}
|
|
1571
1581
|
},
|
|
@@ -1587,99 +1597,10 @@ var appFocus = defineTrigger({
|
|
|
1587
1597
|
};
|
|
1588
1598
|
}
|
|
1589
1599
|
});
|
|
1590
|
-
var src_default =
|
|
1591
|
-
id: "@sdeck/plugin-system",
|
|
1592
|
-
name: "System",
|
|
1593
|
-
version: "0.4.0",
|
|
1594
|
-
description: "Open apps and run commands, press media keys and shortcuts, lock and sleep, take screenshots, and monitor the computer.",
|
|
1595
|
-
author: "sdeck",
|
|
1596
|
-
permissions: ["shell", "process", "input", "network", "filesystem"],
|
|
1597
|
-
settings: {
|
|
1598
|
-
pingHost: { type: "text", label: "Ping host", default: "1.1.1.1" },
|
|
1599
|
-
disks: {
|
|
1600
|
-
type: "text",
|
|
1601
|
-
label: "Disks",
|
|
1602
|
-
placeholder: process.platform === "win32" ? "C:, D:" : "/, /home",
|
|
1603
|
-
description: "Comma separated. Empty means the system disk."
|
|
1604
|
-
},
|
|
1605
|
-
presentMon: {
|
|
1606
|
-
type: "text",
|
|
1607
|
-
label: "PresentMon",
|
|
1608
|
-
default: "PresentMon",
|
|
1609
|
-
description: "Command or full path, for the frame rate (Windows)."
|
|
1610
|
-
}
|
|
1611
|
-
},
|
|
1600
|
+
var src_default = plugin.define({
|
|
1612
1601
|
actions: [open, command, media, hotkey, type, screenshot, lock, sleep, stats, pingAction],
|
|
1613
1602
|
triggers: [appOpen, appClose, appFocus, fileCreated, networkChange, idleTrigger],
|
|
1614
|
-
state: [
|
|
1615
|
-
...monitoring,
|
|
1616
|
-
(() => {
|
|
1617
|
-
let sample;
|
|
1618
|
-
return {
|
|
1619
|
-
id: "cpu",
|
|
1620
|
-
permissions: [],
|
|
1621
|
-
name: "CPU use",
|
|
1622
|
-
type: "number",
|
|
1623
|
-
unit: "%",
|
|
1624
|
-
poll: {
|
|
1625
|
-
everyMs: 2000,
|
|
1626
|
-
read: () => {
|
|
1627
|
-
sample ??= cpuSampler();
|
|
1628
|
-
return sample();
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
};
|
|
1632
|
-
})(),
|
|
1633
|
-
{
|
|
1634
|
-
id: "memory",
|
|
1635
|
-
permissions: [],
|
|
1636
|
-
name: "Memory use",
|
|
1637
|
-
type: "number",
|
|
1638
|
-
unit: "%",
|
|
1639
|
-
poll: { everyMs: 2000, read: () => Math.round(100 * (1 - freemem() / totalmem())) }
|
|
1640
|
-
},
|
|
1641
|
-
{
|
|
1642
|
-
id: "memoryFree",
|
|
1643
|
-
permissions: [],
|
|
1644
|
-
name: "Free memory",
|
|
1645
|
-
type: "number",
|
|
1646
|
-
unit: "bytes",
|
|
1647
|
-
poll: { everyMs: 2000, read: () => freemem() }
|
|
1648
|
-
},
|
|
1649
|
-
{
|
|
1650
|
-
id: "processes",
|
|
1651
|
-
permissions: ["process"],
|
|
1652
|
-
name: "Running processes",
|
|
1653
|
-
type: "json",
|
|
1654
|
-
description: 'Lowercased names; e.g. contains(system.processes, "javaw.exe").',
|
|
1655
|
-
start: (set) => processes.listen((names) => set([...names]))
|
|
1656
|
-
},
|
|
1657
|
-
{
|
|
1658
|
-
id: "idle",
|
|
1659
|
-
permissions: ["process"],
|
|
1660
|
-
name: "Idle time",
|
|
1661
|
-
type: "number",
|
|
1662
|
-
unit: "s",
|
|
1663
|
-
description: "Seconds since the last keyboard or mouse input.",
|
|
1664
|
-
start: (set) => idle.listen(set)
|
|
1665
|
-
},
|
|
1666
|
-
{
|
|
1667
|
-
id: "foreground",
|
|
1668
|
-
permissions: ["process"],
|
|
1669
|
-
name: "App in front",
|
|
1670
|
-
type: "string",
|
|
1671
|
-
description: `The focused window's executable, lowercased ("javaw.exe"); empty when none. Profiles switch on it.`,
|
|
1672
|
-
start: (set) => foreground.listen(set)
|
|
1673
|
-
},
|
|
1674
|
-
{
|
|
1675
|
-
id: "online",
|
|
1676
|
-
permissions: [],
|
|
1677
|
-
name: "Online",
|
|
1678
|
-
type: "boolean",
|
|
1679
|
-
description: "Whether any network interface has an address.",
|
|
1680
|
-
start: (set) => network.listen((addresses) => set(addresses.length > 0))
|
|
1681
|
-
}
|
|
1682
|
-
],
|
|
1603
|
+
state: [...Object.values(values), ...Object.values(monitoring)],
|
|
1683
1604
|
activate(context) {
|
|
1684
1605
|
context.log("ready on", process.platform);
|
|
1685
1606
|
}
|
|
@@ -1728,4 +1649,4 @@ export {
|
|
|
1728
1649
|
xHotkey
|
|
1729
1650
|
};
|
|
1730
1651
|
|
|
1731
|
-
//# debugId=
|
|
1652
|
+
//# debugId=34D39645C7E1BAF064756E2164756E21
|