wmtools/i3bar_base.nim

60 lines
1.2 KiB
Nim

import std/os
import std/json
import std/rdstdin
import marshal
import argparse
type
i3BarData* = object
full_text*: string
short_text*: string
color*: string
border*: string
type
i3BarInput* = object
button*: int
const background* = "#000000"
const backgroundalt* = "#bb222222"
const backgroundalt2* = "#bb333333"
const foreground* = "#dfdfdf"
const foregroundalt* = "#777"
const foregroundalt2* = "#ccc"
const yellow* = "#ffb52a"
const red* = "#e60053"
const purple* = "#9f78e1"
const blue* = "#0a6cf5"
const lightblue* = "#7296EF"
const lighterblue* = "#B5DDF7"
const green* = "#4b9901"
const lightgreen* = "#00ff00"
const grey* = "#dfdfdf"
const darkgrey* = "#444"
const primary* = yellow
const secondary* = red
const alert* = "#bd2c40"
proc debugLog*(str: string) =
let f = open("/tmp/debug.txt",fmAppend)
defer: f.close()
f.writeLine(str)
proc parseInput*(): i3BarInput =
let input = readLineFromStdin("")
debugLog($input)
try:
let jsonNode = parseJson(input)
let i3input = to(jsonNode, i3BarInput)
return i3input
except:
return i3BarInput()
proc getArguments*(): seq[string] =
let args = commandLineParams()
return args
proc outputJSON*(data: i3barData) =
echo $$data