changes to remove i3bar priority
This commit is contained in:
parent
89b73b613c
commit
1c0843d915
18 changed files with 82 additions and 124 deletions
|
@ -4,14 +4,16 @@ import std/rdstdin
|
|||
import marshal
|
||||
|
||||
type
|
||||
i3BarData* = object
|
||||
Info* = object
|
||||
title*: string
|
||||
full_text*: string
|
||||
html_text*: string
|
||||
short_text*: string
|
||||
color*: string
|
||||
border*: string
|
||||
color*: string
|
||||
selected_color*: string
|
||||
background*: string
|
||||
selected_background*: string
|
||||
|
||||
type
|
||||
i3BarInput* = object
|
||||
|
@ -45,13 +47,15 @@ var stoploop* = false
|
|||
var dmenu = false
|
||||
var rofi = false
|
||||
|
||||
proc newi3BarData*(): i3BarData =
|
||||
return i3BarData(
|
||||
proc newInfo*(): Info =
|
||||
return Info(
|
||||
title: "Info : ",
|
||||
full_text: "",
|
||||
short_text: "",
|
||||
color: foreground,
|
||||
selected_color: background,
|
||||
border: white,
|
||||
selected_background: white,
|
||||
background: black
|
||||
)
|
||||
proc debugLog*(str: string) =
|
||||
|
@ -76,31 +80,33 @@ proc getArguments*(): seq[string] =
|
|||
let args = commandLineParams()
|
||||
return args
|
||||
|
||||
proc runDMenu*(data: i3BarData, opts: varargs[string]): string =
|
||||
proc runDMenu*(data: Info, opts: varargs[string]): string =
|
||||
discard execCmd("i3-msg mode \"default\"")
|
||||
var cmd = "echo -e \"" & $data.full_text & "\n"
|
||||
for opt in opts:
|
||||
cmd = cmd & opt & "\n"
|
||||
cmd.removeSuffix("\n")
|
||||
cmd = cmd & "\" | dmenu"
|
||||
#cmd = cmd & " -l 2 "
|
||||
cmd = cmd & " -l " & $(len(opts) + 1)
|
||||
cmd = cmd & " -p \"" & $data.title & "\""
|
||||
cmd = cmd & " -nb \"" & $data.background & "\""
|
||||
cmd = cmd & " -nf \"" & $data.color & "\""
|
||||
cmd = cmd & " -sb \"" & $data.border & "\""
|
||||
cmd = cmd & " -sf \"" & $data.color & "\""
|
||||
cmd = cmd & " -nb \"" & $background & "\""
|
||||
cmd = cmd & " -nf \"" & $foreground & "\""
|
||||
cmd = cmd & " -sb \"" & $data.selected_background & "\""
|
||||
cmd = cmd & " -sf \"" & $data.selected_color & "\""
|
||||
cmd = cmd & " -fn Hermit-10"
|
||||
#echo "Dmenu :", cmd
|
||||
let output = execCmdEx(cmd)
|
||||
let option:string = strip(output[0])
|
||||
discard execCmd("i3-msg mode \"default\"")
|
||||
return option
|
||||
|
||||
proc runRofi*(data: i3BarData) =
|
||||
proc runRofi*(data: Info) =
|
||||
discard execCmd("i3-msg mode \"default\"")
|
||||
var cmd = "rofi"
|
||||
cmd = cmd & " -e \"" & $data.full_text & "\""
|
||||
#echo "Rofi : ", cmd
|
||||
discard execCmd(cmd)
|
||||
discard execCmd("i3-msg mode \"default\"")
|
||||
|
||||
proc outputJSON*(data: i3barData, args: seq[string]): string {.discardable.} =
|
||||
proc outputJSON*(data: Info, args: varargs[string]): string {.discardable.} =
|
||||
var output = ""
|
||||
if dmenu:
|
||||
output = runDMenu(data, args)
|
11
i3bar_battery.nim → battery.nim
Executable file → Normal file
11
i3bar_battery.nim → battery.nim
Executable file → Normal file
|
@ -1,6 +1,5 @@
|
|||
import i3bar_base
|
||||
import base
|
||||
import strutils
|
||||
import std/times
|
||||
import std/os
|
||||
|
||||
proc battery_exists(): bool =
|
||||
|
@ -64,15 +63,17 @@ proc get_design(charge: int, state: bool): (string, string, string, string, stri
|
|||
let text = "<span foreground=\"" & icon_colour & "\">" & icon & "</span>" & $charge & "%"
|
||||
return (text,main_text, col, bg, border)
|
||||
|
||||
proc get_output(charge: int, state: bool): i3barData =
|
||||
proc get_output(charge: int, state: bool): Info =
|
||||
let (text,main_text,col,bg_col,bord_col) = get_design(charge, state)
|
||||
let data = i3barData(
|
||||
let data = Info(
|
||||
title: "Battery : ",
|
||||
full_text: main_text,
|
||||
html_text: text,
|
||||
color: col,
|
||||
border: bord_col,
|
||||
background: bg_col
|
||||
background: bg_col,
|
||||
selected_background: bord_col,
|
||||
selected_color: black
|
||||
)
|
||||
return data
|
||||
|
|
@ -2,12 +2,11 @@ import std/os
|
|||
import strutils
|
||||
import std/osproc
|
||||
import std/math
|
||||
import i3bar_base
|
||||
import base
|
||||
|
||||
proc getLimit(): int
|
||||
|
||||
let limit = getLimit()
|
||||
let args = getArguments()
|
||||
|
||||
proc getLimit(): int =
|
||||
let limit = parseInt(strip(readFile("/sys/class/backlight/intel_backlight/max_brightness")))
|
||||
|
@ -37,10 +36,12 @@ proc get_brightness*(run_once: bool = false) =
|
|||
let pcnt = (current/limit)*100
|
||||
if pcnt != last_pcnt:
|
||||
let text = getDesign(pcnt)
|
||||
var data = newi3BarData()
|
||||
var data = newInfo()
|
||||
data.title = "Brightness : "
|
||||
data.full_text = text
|
||||
data.border = yellow
|
||||
data.selected_background = yellow
|
||||
data.selected_color = black
|
||||
let args = @["up", "down"]
|
||||
let option = outputJSON(data,args)
|
||||
case option:
|
|
@ -2,15 +2,16 @@ import std/os
|
|||
import std/times
|
||||
import std/osproc
|
||||
import std/re
|
||||
import i3bar_base
|
||||
import base
|
||||
|
||||
let args = getArguments()
|
||||
|
||||
proc getObject(date: string): i3barData =
|
||||
var data = newi3barData()
|
||||
proc getObject(date: string): Info =
|
||||
var data = newInfo()
|
||||
data.title = "Date : "
|
||||
data.full_text = date
|
||||
data.border = blue
|
||||
data.selected_background = blue
|
||||
data.selected_color = white
|
||||
return data
|
||||
|
||||
#proc openCalendar(datestr: string) =
|
|
@ -1,6 +1,6 @@
|
|||
import std/times
|
||||
import std/os
|
||||
import i3bar_base
|
||||
import base
|
||||
|
||||
proc get_hour(hr: int): string
|
||||
proc get_minute(min: int): string
|
||||
|
@ -70,12 +70,14 @@ proc get_minute(min: int): string =
|
|||
else:
|
||||
return "error"
|
||||
|
||||
proc getObject(time: string): i3barData =
|
||||
var data = newi3barData()
|
||||
proc getObject(time: string): Info =
|
||||
var data = Info()
|
||||
data.title = "Fuzzy Time :"
|
||||
data.full_text = time
|
||||
data.color = foreground
|
||||
data.border = lightblue
|
||||
data.selected_background = lightblue
|
||||
data.selected_color = black
|
||||
return data
|
||||
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
import std/os
|
||||
import strutils
|
||||
import std/osproc
|
||||
import std/math
|
||||
import i3bar_base
|
||||
import std/threadpool
|
||||
|
||||
proc get_data() =
|
||||
while true:
|
||||
let data1 = i3barData(
|
||||
full_text: "Hello",
|
||||
color: foreground,
|
||||
border: yellow,
|
||||
background: black
|
||||
)
|
||||
outputJSON(data1)
|
||||
sleep(1000)
|
||||
let data2 = i3barData(
|
||||
full_text: "Bye",
|
||||
color: foreground,
|
||||
border: yellow,
|
||||
background: black
|
||||
)
|
||||
outputJSON(data2)
|
||||
sleep(1000)
|
||||
|
||||
proc await_click_info() =
|
||||
while true:
|
||||
let input = parseInput()
|
||||
case input.button:
|
||||
of 1,4:
|
||||
get_data()
|
||||
of 3,5:
|
||||
get_data()
|
||||
else:
|
||||
let no = false
|
||||
|
||||
clearInput(2)
|
||||
|
||||
proc main() =
|
||||
spawn get_data()
|
||||
spawn await_click_info()
|
||||
sync()
|
||||
|
||||
main()
|
|
@ -4,7 +4,6 @@ import std/re
|
|||
import std/httpclient
|
||||
import std/os
|
||||
import std/times
|
||||
import std/osproc
|
||||
|
||||
const url* = "https://www.tidetimes.org.uk/%LOC-tide-times"
|
||||
const loc* = "exmouth-dock"
|
||||
|
@ -43,6 +42,7 @@ proc getTideData(gettomorrow: bool = false): seq[Tide] =
|
|||
link &= "-" & tomdate.format("yyyyMMdd")
|
||||
try:
|
||||
let data = client.getContent(link)
|
||||
echo "Data : " & data
|
||||
let times = findAll(data,fnd)
|
||||
var tide: Tide
|
||||
var count: int = 0
|
||||
|
@ -86,14 +86,15 @@ proc getDesign(tides: seq[Tide]): i3barData =
|
|||
|
||||
proc getTides*() {.gcsafe.}=
|
||||
var mytides = TideList()
|
||||
var last_data = ""
|
||||
var last_data = "-1"
|
||||
while true:
|
||||
if len(mytides.Tides) == 0 or mytides.LastUpdated < now() - initTimeInterval(hours = 1):
|
||||
mytides.Tides = getTideData()
|
||||
mytides.LastUpdated = now()
|
||||
let data = getDesign(sortTides(mytides.Tides))
|
||||
if $data != last_data:
|
||||
outputJSON(data)
|
||||
let args: seq[string] = @[]
|
||||
outputJSON(data,args)
|
||||
last_data = $data
|
||||
if stoploop:
|
||||
break
|
||||
|
@ -102,4 +103,5 @@ proc getTides*() {.gcsafe.}=
|
|||
proc main() =
|
||||
getTides()
|
||||
|
||||
main()
|
||||
if isMainModule:
|
||||
main()
|
||||
|
|
0
i3bar_wlan_threads.nim → i3bar_tools/i3bar_wlan_threads.nim
Executable file → Normal file
0
i3bar_wlan_threads.nim → i3bar_tools/i3bar_wlan_threads.nim
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
import i3bar_base
|
||||
import base
|
||||
import std/os
|
||||
import std/osproc
|
||||
import strutils
|
||||
|
@ -22,11 +22,13 @@ proc get_net(nic: string): (string, string) =
|
|||
return ("disconnected", state)
|
||||
return (ip, state)
|
||||
|
||||
proc getObject(conn: string, nic: string): i3barData =
|
||||
var data = newi3barData()
|
||||
proc getObject(conn: string, nic: string): Info =
|
||||
var data = newInfo()
|
||||
data.title = "IP :"
|
||||
data.full_text = conn
|
||||
data.border = purple
|
||||
data.selected_background = purple
|
||||
data.selected_color = black
|
||||
return data
|
||||
|
||||
proc get_net_info*(nic: string) =
|
|
@ -2,8 +2,7 @@ import std/os
|
|||
import std/osproc
|
||||
import std/re
|
||||
import strutils
|
||||
import i3bar_base
|
||||
import std/math
|
||||
import base
|
||||
|
||||
const host: string = "web.wilde.cloud"
|
||||
const cmd: string = "ping -4 -c 1 " & host
|
||||
|
@ -22,7 +21,7 @@ proc get_ping(): float =
|
|||
ping = parseFloat(png)
|
||||
return ping
|
||||
|
||||
proc getObject(ping: float): i3barData =
|
||||
proc getObject(ping: float): Info =
|
||||
let pingstr = split($ping,".")
|
||||
let niceping = pingstr[0] & "." & pingstr[1][0]
|
||||
var text = "🏓 " & niceping & " ms"
|
||||
|
@ -41,26 +40,16 @@ proc getObject(ping: float): i3barData =
|
|||
else:
|
||||
col = red
|
||||
|
||||
let data = i3barData(
|
||||
title: "Ping Clock:",
|
||||
full_text: text,
|
||||
color: col,
|
||||
border: blue,
|
||||
background: black
|
||||
)
|
||||
var data = newInfo()
|
||||
data.title = "Ping Clock:"
|
||||
data.full_text = text
|
||||
data.color = col
|
||||
data.border = blue
|
||||
data.background = black
|
||||
data.selected_background = blue
|
||||
data.selected_color = white
|
||||
return data
|
||||
|
||||
proc runDMenu(data: i3BarData) =
|
||||
var cmd = "echo " & $data.full_text & " | dmenu "
|
||||
#cmd = cmd & " -l 2 "
|
||||
cmd = cmd & " -p \"Ping Clock : \""
|
||||
cmd = cmd & " -nb \"" & $data.background & "\""
|
||||
cmd = cmd & " -nf \"" & $data.color & "\""
|
||||
cmd = cmd & " -sb \"" & $data.border & "\""
|
||||
cmd = cmd & " -sf \"" & $data.color & "\""
|
||||
discard execCmd(cmd)
|
||||
discard execCmd("i3-msg mode \"default\"")
|
||||
|
||||
|
||||
proc main() =
|
||||
var last_ping: float = 0
|
|
@ -2,7 +2,7 @@ import std/os
|
|||
import std/re
|
||||
import std/math
|
||||
import strutils
|
||||
import i3bar_base
|
||||
import base
|
||||
|
||||
|
||||
proc getThermalZones(): seq[string] =
|
||||
|
@ -27,7 +27,7 @@ proc getAverageTemp(zones: seq[string]): int =
|
|||
let avgtemp = ceil((temps / len(zones))/1000)
|
||||
return toInt(round(avgtemp,0))
|
||||
|
||||
proc getObject(temp: int): i3barData =
|
||||
proc getObject(temp: int): Info =
|
||||
var icon = ""
|
||||
var colour = foreground
|
||||
case temp:
|
||||
|
@ -42,12 +42,14 @@ proc getObject(temp: int): i3barData =
|
|||
icon = ""
|
||||
let text = "<span foreground='" & colour & "'>" & icon & "</span> " & $temp & "°C"
|
||||
let main_text = icon & " " & $temp & "°C"
|
||||
var data = newi3barData()
|
||||
var data = newInfo()
|
||||
data.title = "Temp : "
|
||||
data.full_text = main_text
|
||||
data.html_text = text
|
||||
data.color = foreground
|
||||
data.border = colour
|
||||
data.selected_background = colour
|
||||
data.selected_color = black
|
||||
return data
|
||||
|
||||
proc main() =
|
|
@ -2,7 +2,7 @@ import std/os
|
|||
import strutils
|
||||
import std/osproc
|
||||
import std/math
|
||||
import i3bar_base
|
||||
import base
|
||||
|
||||
proc get_current_volume(): string {.gcsafe.}
|
||||
|
||||
|
@ -48,14 +48,15 @@ proc get_volume*(run_once: bool = false) =
|
|||
let vol = get_current_volume()
|
||||
if vol != last_vol or true:
|
||||
let (text, main_text) = getDesign(vol)
|
||||
let data = i3barData(
|
||||
title: "Volume : ",
|
||||
html_text: text,
|
||||
full_text: main_text,
|
||||
color: foreground,
|
||||
border: green,
|
||||
background: black
|
||||
)
|
||||
var data = Info()
|
||||
data.title = "Volume : "
|
||||
data.html_text = text
|
||||
data.full_text = main_text
|
||||
data.color = foreground
|
||||
data.border = green
|
||||
data.background = black
|
||||
data.selected_background = green
|
||||
data.selected_color = black
|
||||
let args = @["up", "down", "mute", "ncpamixer", "pavucontrol"]
|
||||
let option = outputJSON(data,args)
|
||||
case option:
|
14
i3bar_wlan.nim → wlan.nim
Executable file → Normal file
14
i3bar_wlan.nim → wlan.nim
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
|||
import i3bar_base
|
||||
import base
|
||||
import std/os
|
||||
import std/osproc
|
||||
import strutils
|
||||
|
@ -26,11 +26,13 @@ proc get_wifi(): (string, string) =
|
|||
let quality = get_signal_quality()
|
||||
return (essid, quality)
|
||||
|
||||
proc getObject(conn: string): i3barData =
|
||||
var data = newi3barData()
|
||||
proc getObject(conn: string): Info =
|
||||
var data = newInfo()
|
||||
data.title = "WiFi : "
|
||||
data.full_text = conn
|
||||
data.border = purple
|
||||
data.selected_background = purple
|
||||
data.selected_color = black
|
||||
return data
|
||||
|
||||
proc get_wifi_info*() =
|
||||
|
@ -50,12 +52,6 @@ proc get_wifi_info*() =
|
|||
break
|
||||
sleep(1000)
|
||||
|
||||
proc await_click_info() =
|
||||
while true:
|
||||
let input = parseInput()
|
||||
if input.button == 1:
|
||||
discard execCmd("alacritty -e nmtui-connect")
|
||||
|
||||
proc main() =
|
||||
if dirExists("/sys/class/net/" & wlan_nic):
|
||||
get_wifi_info()
|
Loading…
Reference in a new issue