Skip to content

Instantly share code, notes, and snippets.

@xenogenesi
Created April 9, 2020 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xenogenesi/226e5f04677f041332f7e546054e238c to your computer and use it in GitHub Desktop.
Save xenogenesi/226e5f04677f041332f7e546054e238c to your computer and use it in GitHub Desktop.
nitrogen random configuration for two screen in nim
import os,
re,
strformat,
random
var bgDir = ""
if paramCount() > 0:
bgDir = paramStr(1)
else:
echo "usage: nitrogenrnd [directory]"
quit(1)
var count = 0
var i: int
if existsDir(bgDir):
randomize()
var bgFile0 = ""
var bgFile1 = ""
var rndFile0: int
var rndFile1: int
for file in walkDirRec bgDir:
if file.match re".*\.(jpg|png)":
inc(count)
rndFile0 = rand(count)
rndFile1 = rand(count)
i = 0
for file in walkDirRec bgDir:
if file.match re".*\.(jpg|png)":
if i == rndFile0:
bgFile0 = file
elif i == rndFile1:
bgFile1 = file
inc(i)
echo fmt"""[xin_0]
file={bgFile0}
mode=0
bgcolor=#000000
[xin_1]
file={bgFile1}
mode=0
bgcolor=#000000
"""
else:
quit(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment