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