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

Syntax error when using world clocks #33

Closed
johanbrandhorst opened this issue May 9, 2021 · 11 comments · Fixed by #36
Closed

Syntax error when using world clocks #33

johanbrandhorst opened this issue May 9, 2021 · 11 comments · Fixed by #36
Labels
wontfix This will not be worked on

Comments

@johanbrandhorst
Copy link

Thanks for this great tool! I installed from master using

$ nix-env -i -f https://github.com/gvolpe/dconf2nix/archive/master.tar.gz

And when I ran it, it produce the following incorrect line:

"org/gnome/clocks" = {
  world-clocks = ""[{'location': <(uint32 2, <('San Francisco', 'KOAK', true, [(0.65832848982162007, -2.133408063190589)], [(0.659296885757089, -2.1366218601153339)])>)>}, {'location': <(uint32 2, <('London', 'EGWU', true, [(0.89971722940307675, -0.007272211034407213)], [(0.89884456477707964, -0.0020362232784242244)])>)>}, {'location': <(uint32 2, <('Stockholm', 'ESSB', true, [(1.0358529110586345, 0.31328660073298215)], [(1.0355620170322046, 0.31503192998497648)])>)>}]"";
};

The double quotes cause a parsing error.

I also ran into #31, though that issue was closed, so I'm a little confused what happened there.

@gvolpe
Copy link
Collaborator

gvolpe commented May 11, 2021

@johanbrandhorst are you sure the double quotes are necessary? The protocol does not mention this at all.

@gvolpe
Copy link
Collaborator

gvolpe commented May 11, 2021

Or are you suggesting dconf2nix produces the double quotes? In such case, could you please provide the input to the program?

@johanbrandhorst
Copy link
Author

Yes, dconf2nix produced the double quotes. I can't reproduce right now, but I think the key looked like this:

[org/gnome/shell/extensions/dash-to-panel]
panel-element-positions="'{"0":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":false,"position":"stackedBR"}]}'"

Which produces

# Generated via dconf2nix: https://github.com/gvolpe/dconf2nix
{ lib, ... }:

let
  mkTuple = lib.hm.gvariant.mkTuple;
in
{
  dconf.settings = {
    "org/gnome/shell/extensions/dash-to-panel" = {
      panel-element-positions = ""'{"0":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":false,"position":"stackedBR"}]}'"";
    };

  };
}

@gvolpe
Copy link
Collaborator

gvolpe commented May 12, 2021

I wonder if that's a valid input at all. Was that generated by dconf? I can see how the dconf2nix parser gets confused with the double quotes, as they are not escaped.

@johanbrandhorst
Copy link
Author

The original error was produced using dconf dump | dconf2nix, yeah. I went through the process of manually configuring all my settings imperatively before dumping it, and it produced the double quotes, so I think that's the format that dash-to-panel saves the state in when configured manually.

@gvolpe
Copy link
Collaborator

gvolpe commented May 12, 2021

Usually, dconf generates such values wraped in single quotes, I'm quite suspicious of that value wrapped in both double and single quotes.

[org/gnome/shell/extensions/dash-to-panel]
panel-element-positions='{"0":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":false,"position":"stackedBR"}]}'

Parsing this content, dconf2nix generates the following output, which is valid nix.

# Generated via dconf2nix: https://github.com/gvolpe/dconf2nix
{ lib, ... }:

let
  mkTuple = lib.hm.gvariant.mkTuple;
in
{
  dconf.settings = {
    "org/gnome/shell/extensions/dash-to-panel" = {
      panel-element-positions = "'{"0":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":false,"position":"stackedBR"}]}'";
    };

  };
}

Can you check if this works for you? Not sure how HM will process this result back to dconf. If this is the case, then that solves the problem :)

Otherwise, I'd need more proof that a value can be wrapped in double and single quotes at the same time. FWIW this can be solved too in the Nix generator (the parser does not have issues with it) but I want to make sure there is a problem to solve first.

@johanbrandhorst
Copy link
Author

I don't know where the double quote came from, but it was there when I debugged it. I fixed it manually already and I don't disagree that dconf2nix does the right thing with that input, but I am certain that I didn't manually insert any double quotes into the initial dconf database values. It's up to you whether you want to handle this strange corner case or not, I just wanted to be a good citizen and raise an issue I had with the software.

@gvolpe gvolpe added the wontfix This will not be worked on label May 13, 2021
@gvolpe
Copy link
Collaborator

gvolpe commented May 13, 2021

Thanks for raising the issue. I'll close it for now but if it ever comes back, the (relevant) dconf dump should be shared immediately to be able to reproduce and properly fix.

@gvolpe gvolpe closed this as completed May 13, 2021
@johanbrandhorst
Copy link
Author

I can still reproduce this with v0.0.7. The following dconf.dump (abbreviated):

[org/gnome/clocks]
world-clocks="[{'location': <(uint32 2, <('San Francisco', 'KOAK', true, [(0.65832848982162007, -2.133408063190589)], [(0.659296885757089, -2.1366218601153339)])>)>}, {'location': <(uint32 2, <('London', 'EGWU', true, [(0.89971722940307675, -0.007272211034407213)], [(0.89884456477707964, -0.0020362232784242244)])>)>}, {'location': <(uint32 2, <('Stockholm', 'ESSB', true, [(1.0358529110586345, 0.31328660073298215)], [(1.0355620170322046, 0.31503192998497648)])>)>}]"

[org/gnome/shell/extensions/dash-to-panel]
panel-element-positions='{"0":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":false,"position":"stackedBR"}]}'

Produces the following file:

# Generated via dconf2nix: https://github.com/gvolpe/dconf2nix
{ lib, ... }:

let
  mkTuple = lib.hm.gvariant.mkTuple;
in
{
  dconf.settings = {
    "org/gnome/clocks" = {
      world-clocks = ""[{'location': <(uint32 2, <('San Francisco', 'KOAK', true, [(0.65832848982162007, -2.133408063190589)], [(0.659296885757089, -2.1366218601153339)])>)>}, {'location': <(uint32 2, <('London', 'EGWU', true, [(0.89971722940307675, -0.007272211034407213)], [(0.89884456477707964, -0.0020362232784242244)])>)>}, {'location': <(uint32 2, <('Stockholm', 'ESSB', true, [(1.0358529110586345, 0.31328660073298215)], [(1.0355620170322046, 0.31503192998497648)])>)>}]"";
    };

    "org/gnome/shell/extensions/dash-to-panel" = {
      panel-element-positions = "'{"0":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":false,"position":"stackedBR"}]}'";
    };

  };
}

Neither lines of which are valid nix as far as my home-manager switch is concerned (in conflict with your suggestion in #33 (comment)).

@gvolpe gvolpe reopened this May 23, 2021
@johanbrandhorst
Copy link
Author

johanbrandhorst commented Jun 13, 2021

The second part of this issue is still present in v0.0.8, the incorrect translation of the panel-element-positions. The following input:

[org/gnome/shell/extensions/dash-to-panel]
panel-element-positions='{"0":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":false,"position":"stackedBR"}]}'

Produces the following output:

# Generated via dconf2nix: https://github.com/gvolpe/dconf2nix
{ lib, ... }:

let
  mkTuple = lib.hm.gvariant.mkTuple;
in
{
  dconf.settings = {
    "org/gnome/shell/extensions/dash-to-panel" = {
      panel-element-positions = "'{"0":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":true,"position":"stackedBR"}],"1":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":true,"position":"stackedBR"}]}'";
  };
}

The quotes inside of the double quotes should be escaped, I think.

@gvolpe
Copy link
Collaborator

gvolpe commented Jun 14, 2021

That's fixed in master but it depends on whether HM supports JSON entries or not, see #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants