use global flag to load config
This commit is contained in:
parent
884cb9c68c
commit
44b25bdf70
5 changed files with 22 additions and 15 deletions
|
@ -48,7 +48,7 @@
|
||||||
pname = "hyprman";
|
pname = "hyprman";
|
||||||
version = "unstable";
|
version = "unstable";
|
||||||
src = cleanSource ./.;
|
src = cleanSource ./.;
|
||||||
nimbleDepsHash = "sha256-OqyB91B9bjyZXavb4Ikv2wMpH8UPsTGn2dmqiX8IFT0=";
|
nimbleDepsHash = "sha256-tDhf7CrHtgtu9NNFzp3swnfeMYBFrvHsFwR0JeYul7Q=";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
|
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
|
||||||
|
|
|
@ -13,4 +13,4 @@ bin = @["hyprman"]
|
||||||
requires "nim >= 2.0.8"
|
requires "nim >= 2.0.8"
|
||||||
requires "yaml"
|
requires "yaml"
|
||||||
requires "jsony"
|
requires "jsony"
|
||||||
requires "https://github.com/daylinmorgan/hwylterm#65a952e"
|
requires "https://github.com/daylinmorgan/hwylterm#f1cc95f8"
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
"packages": {
|
"packages": {
|
||||||
"hwylterm": {
|
"hwylterm": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"vcsRevision": "65a952e9f0d75659d39f8a3b146753e291ee0a66",
|
"vcsRevision": "f1cc95f86edcc00665fc8280f57edc0e83d461f9",
|
||||||
"url": "https://github.com/daylinmorgan/hwylterm",
|
"url": "https://github.com/daylinmorgan/hwylterm",
|
||||||
"downloadMethod": "git",
|
"downloadMethod": "git",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"checksums": {
|
"checksums": {
|
||||||
"sha1": "10894d492bbe1d0ea32ee9bb0686abfcd3b0b0fe"
|
"sha1": "433522bac3b8f3caae252a1a42867ed8dc91f4d2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"jsony": {
|
"jsony": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
## hyprman, the hyprland companion
|
## hyprman, the hyprland companion
|
||||||
|
|
||||||
import std/[osproc, strformat]
|
import std/[os, osproc, strformat]
|
||||||
import hwylterm/hwylcli
|
import hwylterm/hwylcli
|
||||||
import ./[
|
import ./[
|
||||||
hyprland,
|
hyprland,
|
||||||
|
@ -10,8 +10,17 @@ import ./[
|
||||||
|
|
||||||
hwylCli:
|
hwylCli:
|
||||||
name "hyprman"
|
name "hyprman"
|
||||||
|
flags:
|
||||||
|
[global]
|
||||||
|
config:
|
||||||
|
i configPath
|
||||||
|
T string
|
||||||
|
? "path to config file"
|
||||||
|
* (getConfigDir() / "hyprman" / "config.yml")
|
||||||
|
- c
|
||||||
|
preSub:
|
||||||
|
config.load(configPath)
|
||||||
subcommands:
|
subcommands:
|
||||||
|
|
||||||
[mako]
|
[mako]
|
||||||
... "interact with mako"
|
... "interact with mako"
|
||||||
flags:
|
flags:
|
||||||
|
@ -19,7 +28,6 @@ hwylCli:
|
||||||
T int
|
T int
|
||||||
? "# of notifications"
|
? "# of notifications"
|
||||||
* 10
|
* 10
|
||||||
- c
|
|
||||||
json:
|
json:
|
||||||
? "output as json"
|
? "output as json"
|
||||||
- j
|
- j
|
||||||
|
|
15
src/lib.nim
15
src/lib.nim
|
@ -20,12 +20,13 @@ type
|
||||||
`no-client`*: string
|
`no-client`*: string
|
||||||
`default-icon`*: string
|
`default-icon`*: string
|
||||||
|
|
||||||
proc loadConfig*(): Config =
|
var config*: Config
|
||||||
let configPath = getConfigDir() / "hyprman" / "config.yml"
|
|
||||||
if fileExists(configPath):
|
proc load*(c: var Config, p: string) =
|
||||||
var s = newFileStream(configPath)
|
if fileExists(p):
|
||||||
load(s, result)
|
var s = newFileStream(p)
|
||||||
result.wallpapers = expandTilde(result.wallpapers)
|
load(s, c)
|
||||||
|
c.wallpapers = expandTilde(c.wallpapers)
|
||||||
|
|
||||||
func pickIcon*(
|
func pickIcon*(
|
||||||
c: Config,
|
c: Config,
|
||||||
|
@ -35,5 +36,3 @@ func pickIcon*(
|
||||||
if class in k: result = v
|
if class in k: result = v
|
||||||
if result == "":
|
if result == "":
|
||||||
result = c.`default-icon`
|
result = c.`default-icon`
|
||||||
|
|
||||||
let config* = loadConfig()
|
|
||||||
|
|
Loading…
Reference in a new issue