added wirelurrs

This commit is contained in:
Paul Wilde 2023-11-23 19:40:20 +00:00
parent 8010714091
commit e6a72669ba
5 changed files with 26 additions and 37 deletions

View file

@ -5,6 +5,7 @@ import util/pingclock
import util/batturry import util/batturry
import util/volurrme import util/volurrme
import util/netwurrk import util/netwurrk
import util/wirelurrs
import util/emurrji import util/emurrji
import util/calendurr import util/calendurr
import util/remminurr import util/remminurr
@ -27,6 +28,8 @@ proc dispatch*(cfg: Config) =
volurrme.go() volurrme.go()
of Netwurrk: of Netwurrk:
netwurrk.go() netwurrk.go()
of Wirelurrs:
wirelurrs.go()
of Emurrji: of Emurrji:
emurrji.go() emurrji.go()
of Calendurr: of Calendurr:

View file

@ -7,6 +7,7 @@ type
Batturry, Batturry,
Volurrme, Volurrme,
Netwurrk, Netwurrk,
Wirelurrs,
Emurrji, Emurrji,
Calendurr, Calendurr,
Remminurr, Remminurr,

View file

@ -27,6 +27,8 @@ proc parseArgs*() =
myConfig.run = Volurrme myConfig.run = Volurrme
of "netwurrk", "network", "net": of "netwurrk", "network", "net":
myConfig.run = Netwurrk myConfig.run = Netwurrk
of "wirelurrs", "wireless", "wifi":
myConfig.run = Wirelurrs
of "emurrji", "emoji": of "emurrji", "emoji":
myConfig.run = Emurrji myConfig.run = Emurrji
of "calendurr", "calender", "cal": of "calendurr", "calender", "cal":

View file

@ -1,22 +0,0 @@
import ../../globurrl
import std/[strutils,osproc]
# Basically just a wrapper to style passmenu nicely
proc main() =
var info = newInfo(capitalizeAscii(run_command))
let cmd = genMenuCmd(info)
discard execCmd(cmd)
return
if isMainModule:
globurrl.wrappurr = true
for idx, arg in args:
case arg:
of "-r", "--run":
run_command = args[idx + 1]
break
else:
echo "No command given, please run again with `[-r|--run] __cmd__`"
if run_command != "":
main()

View file

@ -1,9 +1,11 @@
import ../../globurrl import os
import std/[os,osproc,strutils,sequtils] import osproc
import strutils
import sequtils
import ../common
import ../output
const default_bg = purple
const default_fg = white
const wlan_nics: seq[string] = @["wlan0"]
const get_ssid_cmd = "iwgetid -r" const get_ssid_cmd = "iwgetid -r"
const mng_cmd = "alacritty -e nmtui-connect" const mng_cmd = "alacritty -e nmtui-connect"
@ -28,9 +30,6 @@ proc getWifi(nic: string): (string, string) =
proc getObject(): Info = proc getObject(): Info =
var data = newInfo("Wirelurrs") var data = newInfo("Wirelurrs")
data.border = purple
data.selected_bg = default_bg
data.selected_fg = default_fg
return data return data
proc getWifiInfo*(nics: seq[string]) = proc getWifiInfo*(nics: seq[string]) =
@ -41,6 +40,8 @@ proc getWifiInfo*(nics: seq[string]) =
let data = getObject() let data = getObject()
let args = concat(lst,@["---", "manage","exit"]) let args = concat(lst,@["---", "manage","exit"])
let output = outputData(data, args) let output = outputData(data, args)
if output in lst:
discard execCmd(mng_cmd)
case output: case output:
of "manage": of "manage":
discard execCmd(mng_cmd) discard execCmd(mng_cmd)
@ -49,16 +50,20 @@ proc getWifiInfo*(nics: seq[string]) =
of "---": of "---":
return return
proc main() = proc getWiFiNICs(): seq[string] =
var my_nics: seq[string] = @[] var my_nics: seq[string] = @[]
for nic in wlan_nics: for path in walkDir("/sys/class/net/"):
if dirExists("/sys/class/net/" & nic): if dirExists(path.path & "/wireless"):
let nic = path.path.replace("/sys/class/net/","")
my_nics.add(nic) my_nics.add(nic)
return my_nics
proc go*() =
let my_nics = getWiFiNICs()
if len(my_nics) > 0: if len(my_nics) > 0:
getWifiInfo(my_nics) getWifiInfo(my_nics)
else: else:
switchTwmMode() var data = getObject()
echo "No WLAN" data.full_text = "No WLAN"
discard outputData(data)
if isMainModule:
main()