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/volurrme
import util/netwurrk
import util/wirelurrs
import util/emurrji
import util/calendurr
import util/remminurr
@ -27,6 +28,8 @@ proc dispatch*(cfg: Config) =
volurrme.go()
of Netwurrk:
netwurrk.go()
of Wirelurrs:
wirelurrs.go()
of Emurrji:
emurrji.go()
of Calendurr:

View file

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

View file

@ -27,6 +27,8 @@ proc parseArgs*() =
myConfig.run = Volurrme
of "netwurrk", "network", "net":
myConfig.run = Netwurrk
of "wirelurrs", "wireless", "wifi":
myConfig.run = Wirelurrs
of "emurrji", "emoji":
myConfig.run = Emurrji
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 std/[os,osproc,strutils,sequtils]
import os
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 mng_cmd = "alacritty -e nmtui-connect"
@ -28,9 +30,6 @@ proc getWifi(nic: string): (string, string) =
proc getObject(): Info =
var data = newInfo("Wirelurrs")
data.border = purple
data.selected_bg = default_bg
data.selected_fg = default_fg
return data
proc getWifiInfo*(nics: seq[string]) =
@ -41,6 +40,8 @@ proc getWifiInfo*(nics: seq[string]) =
let data = getObject()
let args = concat(lst,@["---", "manage","exit"])
let output = outputData(data, args)
if output in lst:
discard execCmd(mng_cmd)
case output:
of "manage":
discard execCmd(mng_cmd)
@ -49,16 +50,20 @@ proc getWifiInfo*(nics: seq[string]) =
of "---":
return
proc main() =
proc getWiFiNICs(): seq[string] =
var my_nics: seq[string] = @[]
for nic in wlan_nics:
if dirExists("/sys/class/net/" & nic):
for path in walkDir("/sys/class/net/"):
if dirExists(path.path & "/wireless"):
let nic = path.path.replace("/sys/class/net/","")
my_nics.add(nic)
return my_nics
proc go*() =
let my_nics = getWiFiNICs()
if len(my_nics) > 0:
getWifiInfo(my_nics)
else:
switchTwmMode()
echo "No WLAN"
var data = getObject()
data.full_text = "No WLAN"
discard outputData(data)
if isMainModule:
main()