Skip to content

Commit

Permalink
Merge pull request #36 from gvolpe/fix/variants-support
Browse files Browse the repository at this point in the history
Fix variants parser
  • Loading branch information
gvolpe authored May 23, 2021
2 parents 04b0ca6 + dd6a1d4 commit c5c5c16
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
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

0 comments on commit c5c5c16

Please sign in to comment.