added pw gen
This commit is contained in:
parent
a97f3738b2
commit
b866811ab8
3 changed files with 22 additions and 13 deletions
12
globurrl.nim
12
globurrl.nim
|
@ -125,14 +125,6 @@ proc debugLog*(str: string) =
|
||||||
defer: f.close()
|
defer: f.close()
|
||||||
f.writeLine(str)
|
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() =
|
proc checkWayland() =
|
||||||
if getEnv("XDG_SESSION_TYPE") == "wayland":
|
if getEnv("XDG_SESSION_TYPE") == "wayland":
|
||||||
wayland = true
|
wayland = true
|
||||||
|
@ -264,10 +256,6 @@ proc checkCacheDir() =
|
||||||
|
|
||||||
# At Start up:
|
# At Start up:
|
||||||
checkCacheDir()
|
checkCacheDir()
|
||||||
checkWayland()
|
|
||||||
|
|
||||||
# Switch bindsym mode back to default as it could be being used.
|
|
||||||
switchTwmMode()
|
|
||||||
|
|
||||||
|
|
||||||
let args* = getArguments()
|
let args* = getArguments()
|
||||||
|
|
1
pw_generaturr/nim.cfg
Normal file
1
pw_generaturr/nim.cfg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
-d:ssl
|
|
@ -2,13 +2,33 @@ import ../../globurrl
|
||||||
|
|
||||||
import httpclient
|
import httpclient
|
||||||
import json
|
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() =
|
proc getPW() =
|
||||||
var c = newHttpClient()
|
var c = newHttpClient()
|
||||||
try:
|
try:
|
||||||
let resp = c.get("https://random-word-api.herokuapp.com/word?length=5")
|
let resp = c.get("https://random-word-api.herokuapp.com/word?length=5")
|
||||||
if resp.status == $Http200:
|
if resp.status == $Http200:
|
||||||
echo resp.body.parseJson
|
parsePw(resp.body)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
echo getCurrentExceptionMsg()
|
echo getCurrentExceptionMsg()
|
||||||
|
|
Loading…
Reference in a new issue