added emoji picker

This commit is contained in:
Paul Wilde 2022-05-09 21:08:54 +01:00
parent dced0c0438
commit 310b8d9c1e
5 changed files with 1596 additions and 1 deletions

View file

@ -16,6 +16,7 @@ which are selectable options in dmenu.
- `temperature` shows the current CPU temperature - `temperature` shows the current CPU temperature
- `notes` a simple one liner note taking tool, displaying notes in `dmenu`/`rofi` - `notes` a simple one liner note taking tool, displaying notes in `dmenu`/`rofi`
- `calculate` a calculator, utilising `qalculate` - inspired by [@fedops](https://codeberg.org/fedops/scripts) - `calculate` a calculator, utilising `qalculate` - inspired by [@fedops](https://codeberg.org/fedops/scripts)
- `emoji` an emoji picker
The next two do not work with `rofi` unless you have `alias dmenu=rofi` set, but they're pretty nice tools The next two do not work with `rofi` unless you have `alias dmenu=rofi` set, but they're pretty nice tools

View file

@ -178,6 +178,8 @@ proc runDMenu*(data: Info, opts: varargs[string], rofi: bool = false): string =
output.output.stripLineEnd() output.output.stripLineEnd()
return output.output return output.output
proc copyToClipboard*(str: string) =
discard execCmd("echo -n " & quote(str) & " | xclip -selection clipboard")
proc outputData*(data: Info, args: varargs[string]): string {.discardable.} = proc outputData*(data: Info, args: varargs[string]): string {.discardable.} =
var output = "" var output = ""
if rofi: if rofi:

View file

@ -17,7 +17,7 @@ proc doCalculation(calc: string) =
var cmd = outputData(info, args) var cmd = outputData(info, args)
cmd.stripLineEnd() cmd.stripLineEnd()
if cmd in answers: if cmd in answers:
discard execCmd("echo " & quote(cmd) & " | xclip") copyToClipboard(cmd)
elif cmd == "exit" or cmd == "": elif cmd == "exit" or cmd == "":
return return
else: else:

19
emoji.nim Normal file
View file

@ -0,0 +1,19 @@
import base
import lib/codemap
import std/[re,osproc,algorithm]
proc main() =
var info = newInfo("Emoji Picker")
var args = emojiCodemap
args.add("exit")
let output = outputData(info,args)
if output == "exit" or output == "":
return
else:
let e = re.findAll(output,re(".+ :"))
let emoji = re.replace(e[0], re(" :"),"")
copyToClipboard(emoji)
return
if isMainModule:
main()

1573
lib/codemap.nim Normal file

File diff suppressed because it is too large Load diff