[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean variable isn't reactive #260

Closed
hedonicadapter opened this issue Aug 20, 2024 · 0 comments
Closed

Boolean variable isn't reactive #260

hedonicadapter opened this issue Aug 20, 2024 · 0 comments

Comments

@hedonicadapter
Copy link
hedonicadapter commented Aug 20, 2024

I have this in the SystemIndicators file:

import { zenable } from "lib/variables";

const ZenIndicator = () =>
  Widget.Label({
    label: zenable.bind().as((bool) => {
      console.log("ZenIndicator update:", bool);
      return bool ? "zenabled" : "zdisabled";
    }),
  });
  
  
export default () =>
  PanelButton({
    window: "quicksettings",
    on_clicked: () => App.toggleWindow("quicksettings"),
    on_scroll_up: () => (audio.speaker.volume += 0.02),
    on_scroll_down: () => (audio.speaker.volume -= 0.02),
    children: [
      Widget.Box({
        children: [
          ZenIndicator(),
          ...
        ],
      }),
    ],
  });

And in vavriables.ts:

export const zenable = Variable(false);
export const toggleZenable = () => zenable.setValue(!zenable.value);

I can run
ags -r "(await import('file://$HOME/.config/ags/lib/variables.ts')).zenable"
with
ags -r "(await import('file://$HOME/.config/ags/lib/variables.ts')).toggleZenable()"
inbetween and get expected output (true or false), but the change is never reflected in the label

extra info if needed

I'm on NixOS with home-manager, and running ags outputs the following:

(com.github.Aylur.ags:538672): Gjs-Console-CRITICAL **: 13:05:32.991: net.h
adess.PowerProfiles is not available

(com.github.Aylur.ags:538672): Gjs-Console-WARNING **: 13:05:34.028: Error:
 expected Pixbuf or string for icon, but got undefined
set icon@resource:///com/github/Aylur/ags/widgets/icon.js:53:26
bind/callback<@resource:///com/github/Aylur/ags/widgets/widget.js:53:30
hook/<@resource:///com/github/Aylur/ags/widgets/widget.js:43:25
_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/module
s/core/overrides/GLib.js:266:34
  

(com.github.Aylur.ags:538672): Gjs-Console-WARNING **: 13:05:34.028: Error:
 expected Pixbuf or string for icon, but got undefined
set icon@resource:///com/github/Aylur/ags/widgets/icon.js:53:26
bind/callback<@resource:///com/github/Aylur/ags/widgets/widget.js:53:30
hook/<@resource:///com/github/Aylur/ags/widgets/widget.js:43:25
_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/module
s/core/overrides/GLib.js:266:34
  
Gjs-Console-Message: 13:05:34.173: ZenIndicator update: false
Gjs-Console-Message: 13:05:34.189: ZenIndicator update: false

(com.github.Aylur.ags:538672): GLib-GObject-CRITICAL **: 13:05:34.409: valu
e "-0,070000" of type 'gdouble' is invalid or out of range for property 'va
lue' of type 'gdouble'

(com.github.Aylur.ags:538672): GLib-GObject-CRITICAL **: 13:05:34.409: valu
e "-0,070000" of type 'gdouble' is invalid or out of range for property 'va
lue' of type 'gdouble'

(com.github.Aylur.ags:538672): GLib-GObject-CRITICAL **: 13:05:34.409: valu
e "-0,070000" of type 'gdouble' is invalid or out of range for property 'va
lue' of type 'gdouble'

(com.github.Aylur.ags:538672): GLib-GObject-CRITICAL **: 13:05:34.413: valu
e "-0,070000" of type 'gdouble' is invalid or out of range for property 'va
lue' of type 'gdouble'

(com.github.Aylur.ags:538672): GLib-GObject-CRITICAL **: 13:05:34.413: valu
e "-0,070000" of type 'gdouble' is invalid or out of range for property 'va
lue' of type 'gdouble'

(com.github.Aylur.ags:538672): GLib-GObject-CRITICAL **: 13:05:34.413: valu
e "-0,070000" of type 'gdouble' is invalid or out of range for property 'va
lue' of type 'gdouble'
@Aylur Aylur closed this as completed Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants