From 079c5d9526827fa8d9bd977601497a5ef433b80d Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Thu, 23 Nov 2023 10:02:06 +0000 Subject: [PATCH] added reminurr --- src/dispatcher.nim | 3 ++ src/model/tool.nim | 3 +- src/output.nim | 2 +- src/parser.nim | 2 ++ .../remmina_choosurr/remmina_choosurr.nimble | 14 --------- .../remmina_choosurr.nim => remminurr.nim} | 30 ++++++++----------- wm_tools.nimble | 1 + 7 files changed, 21 insertions(+), 34 deletions(-) delete mode 100644 src/util/remmina_choosurr/remmina_choosurr.nimble rename src/util/{remmina_choosurr/src/remmina_choosurr.nim => remminurr.nim} (83%) diff --git a/src/dispatcher.nim b/src/dispatcher.nim index 6a7c3f0..ca7efa3 100644 --- a/src/dispatcher.nim +++ b/src/dispatcher.nim @@ -7,6 +7,7 @@ import util/volurrme import util/netwurrk import util/emurrji import util/calendurr +import util/remminurr proc dispatch*(cfg: Config) = case cfg.run @@ -24,5 +25,7 @@ proc dispatch*(cfg: Config) = emurrji.go() of Calendurr: calendurr.go() + of Remminurr: + remminurr.go() else: echo "No valid run command given" diff --git a/src/model/tool.nim b/src/model/tool.nim index 8273b72..990e4fa 100644 --- a/src/model/tool.nim +++ b/src/model/tool.nim @@ -8,4 +8,5 @@ type Volurrme, Netwurrk, Emurrji, - Calendurr + Calendurr, + Remminurr diff --git a/src/output.nim b/src/output.nim index ea3ce37..9a18689 100644 --- a/src/output.nim +++ b/src/output.nim @@ -7,7 +7,7 @@ proc stripQuotes(str: string): string = var text = replace(str,"\"",""") return text -proc quote(str: string): string = +proc quote*(str: string): string = var text = str # May need to put some further work to escape some special chars here text = stripQuotes(text) diff --git a/src/parser.nim b/src/parser.nim index d192959..ba8f5a5 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -27,6 +27,8 @@ proc parseArgs*() = myConfig.run = Emurrji of "calendurr", "calender", "cal": myConfig.run = Calendurr + of "remminurr", "remmina", "rdp", "rem": + myConfig.run = Remminurr else: echo p.help quit(1) diff --git a/src/util/remmina_choosurr/remmina_choosurr.nimble b/src/util/remmina_choosurr/remmina_choosurr.nimble deleted file mode 100644 index 5faaf0b..0000000 --- a/src/util/remmina_choosurr/remmina_choosurr.nimble +++ /dev/null @@ -1,14 +0,0 @@ -# Package - -version = "0.1.0" -author = "Paul Wilde" -description = "A Remmina client tool and opener" -license = "GPL-3.0-or-later" -srcDir = "src" -bin = @["remmina_choosurr"] - - -# Dependencies - -requires "nim >= 1.6.6" -requires "configparser >= 0.1.0" diff --git a/src/util/remmina_choosurr/src/remmina_choosurr.nim b/src/util/remminurr.nim similarity index 83% rename from src/util/remmina_choosurr/src/remmina_choosurr.nim rename to src/util/remminurr.nim index b8d21cc..fba8848 100644 --- a/src/util/remmina_choosurr/src/remmina_choosurr.nim +++ b/src/util/remminurr.nim @@ -1,20 +1,18 @@ -import ../../globurrl -import std/[os,osproc,tables,algorithm] +import os +import osproc +import tables +import algorithm + import configparser +import ../common +import ../output + const REMMINA_DIR = getHomeDir() & ".local/share/remmina" -const SWITCH_WS = false -const REMMINA_WS = "4" var sessions = initTable[string,string]() var names: seq[string] = @[] -proc main() - -proc switchWorkspace() = - if SWITCH_WS and REMMINA_WS != "": - discard execCmd("i3-msg workspace number " & REMMINA_WS) - proc getRemminaFiles(): seq[string] = if len(names) < 1: for file in walkFiles(REMMINA_DIR & "/*.remmina"): @@ -38,6 +36,8 @@ proc startRemmina(conn: string) = let session = sessions[conn] discard execCmd("remmina -c " & quote(session)) +proc go*() # adding as need to refer back to it in selectRemmina + proc selectRemmina(conn: string) = var info = newInfo("Remmina Choosurr : " & conn) let args = @["connect", "edit", "back"] @@ -51,11 +51,9 @@ proc selectRemmina(conn: string) = editRemmina(conn) #switchWorkspace() of "back": - main() + go() - - -proc main() = +proc go*() = var info = newInfo("Remmina Choosurr") var args: seq[string] = getRemminaFiles() args.add("new") @@ -68,7 +66,3 @@ proc main() = elif output in names: selectRemmina(output) return - return - -if isMainModule: - main() diff --git a/wm_tools.nimble b/wm_tools.nimble index 9c31683..acddde3 100644 --- a/wm_tools.nimble +++ b/wm_tools.nimble @@ -13,3 +13,4 @@ bin = @["wmtools"] requires "nim >= 2.0.0" requires "parsetoml >= 0.7.1" requires "argparse" +requires "configparser"