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

Fix variants parser #36

Merged
merged 1 commit into from
May 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions data/clocks.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[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"}]}'
18 changes: 18 additions & 0 deletions output/clocks.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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"}]}'";
};

};
}
14 changes: 10 additions & 4 deletions src/DConf.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,17 @@ dconf :: Parsec Text () Value
dconf = choice
[vBool, vInt, vDouble, vUint32, vInt64, vEmptyString, vString, vTuple, vAny]

-- There is no support for variants in HM yet so we parse them as String
-- There is no support for variants in HM yet so we parse them as a string
vListOfVariant :: Parsec Text () Value
vListOfVariant = try $ do
try (lookAhead $ string "[<") <|> try (lookAhead $ string "[{")
S . T.pack <$> manyTill anyToken (try $ lookAhead endOfLine)
vListOfVariant =
let variant1 = try $ do
try (lookAhead $ string "[<") <|> try (lookAhead $ string "[{")
manyTill anyToken (try $ lookAhead endOfLine)
variant2 = try $ do
try (lookAhead $ string "\"[<") <|> try (lookAhead $ string "\"[{")
char '"'
manyTill anyToken (try $ lookAhead $ string "\"") <* char '"'
in S . T.pack <$> (variant1 <|> variant2)

vList :: Parsec Text () Value
vList = try $ do
Expand Down