Skip to content

Commit

Permalink
bar: custom module: custom interval (end-4#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
end-4 committed Feb 27, 2024
1 parent ad86206 commit 3dc2db2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .config/ags/modules/bar/music.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AnimatedCircProg } from "../.commonwidgets/cairo_circularprogress.js";
import { MaterialIcon } from '../.commonwidgets/materialicon.js';
import { showMusicControls } from '../../variables.js';

const CUSTOM_MODULE_CONTENT_INTERVAL_FILE = `${GLib.get_home_dir()}/.cache/ags/user/scripts/custom-module-interval.txt`;
const CUSTOM_MODULE_CONTENT_SCRIPT = `${GLib.get_home_dir()}/.cache/ags/user/scripts/custom-module-poll.sh`;
const CUSTOM_MODULE_LEFTCLICK_SCRIPT = `${GLib.get_home_dir()}/.cache/ags/user/scripts/custom-module-leftclick.sh`;
const CUSTOM_MODULE_RIGHTCLICK_SCRIPT = `${GLib.get_home_dir()}/.cache/ags/user/scripts/custom-module-rightclick.sh`;
Expand Down Expand Up @@ -153,14 +154,15 @@ export default () => {
const SystemResourcesOrCustomModule = () => {
// Check if ~/.cache/ags/user/scripts/custom-module-poll.sh exists
if (GLib.file_test(CUSTOM_MODULE_CONTENT_SCRIPT, GLib.FileTest.EXISTS)) {
const interval = Number(Utils.readFile(CUSTOM_MODULE_CONTENT_INTERVAL_FILE)) || 5000;
return BarGroup({
child: Button({
child: Label({
className: 'txt-smallie txt-onSurfaceVariant',
useMarkup: true,
setup: (self) => Utils.timeout(1, () => {
self.label = exec(CUSTOM_MODULE_CONTENT_SCRIPT);
self.poll(5000, (self) => {
self.poll(interval, (self) => {
const content = exec(CUSTOM_MODULE_CONTENT_SCRIPT);
self.label = content;
})
Expand Down

0 comments on commit 3dc2db2

Please sign in to comment.