added pw gen

This commit is contained in:
Paul Wilde 2023-10-27 11:47:34 +01:00
parent a97f3738b2
commit b866811ab8
3 changed files with 22 additions and 13 deletions

View file

@ -125,14 +125,6 @@ proc debugLog*(str: string) =
defer: f.close()
f.writeLine(str)
proc switchTwmMode*(mode: string = "default") =
# I intend to add support for more twm as time goes on (I switch around a lot)
# Switch out of an i3 bindsym mode if set
if wayland:
discard execCmd("sway mode \"" & mode & "\"")
else:
discard execCmd("i3-msg mode \"" & mode & "\"")
proc checkWayland() =
if getEnv("XDG_SESSION_TYPE") == "wayland":
wayland = true
@ -264,10 +256,6 @@ proc checkCacheDir() =
# At Start up:
checkCacheDir()
checkWayland()
# Switch bindsym mode back to default as it could be being used.
switchTwmMode()
let args* = getArguments()

1
pw_generaturr/nim.cfg Normal file
View file

@ -0,0 +1 @@
-d:ssl

View file

@ -2,13 +2,33 @@ import ../../globurrl
import httpclient
import json
import strutils
import random
var length = 4
proc getNumber(size: int = 4): string =
var num = ""
for _ in countup(1,size):
randomize()
let roll = rand(0..9)
num &= $roll
return num
proc parsePw(body: string) =
let j = body.parseJson
for pass in j.getElems:
var p = pass.getStr.capitalizeAscii
p &= getNumber(length)
echo p
proc getPW() =
var c = newHttpClient()
try:
let resp = c.get("https://random-word-api.herokuapp.com/word?length=5")
if resp.status == $Http200:
echo resp.body.parseJson
parsePw(resp.body)
except:
echo getCurrentExceptionMsg()