From 80eeca7102e7b1032e78aec55e33188150bcfc12 Mon Sep 17 00:00:00 2001 From: traxys Date: Tue, 27 Aug 2024 22:47:40 +0200 Subject: [PATCH] gaming: Add a script to extract wow-notes --- gaming/hm.nix | 1 + pkgs/default.nix | 1 + pkgs/wow-note/default.nix | 7 +++++++ pkgs/wow-note/wow_note.lua | 29 +++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 pkgs/wow-note/default.nix create mode 100755 pkgs/wow-note/wow_note.lua diff --git a/gaming/hm.nix b/gaming/hm.nix index fd8ce87..cc7833b 100644 --- a/gaming/hm.nix +++ b/gaming/hm.nix @@ -18,6 +18,7 @@ xivlauncher obs-studio pulseaudio + wow-note ]; home.file = { diff --git a/pkgs/default.nix b/pkgs/default.nix index 75fd386..0eff30c 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -27,6 +27,7 @@ push-to-talk = pkgs.callPackage ./push-to-talk.nix { }; pulse8-cec = pkgs.callPackage ./pulse8-cec.nix { }; weakauras-companion = pkgs.callPackage ./weakauras-companion.nix { }; + wow-note = pkgs.callPackage ./wow-note { }; }; }; } diff --git a/pkgs/wow-note/default.nix b/pkgs/wow-note/default.nix new file mode 100644 index 0000000..4f4089a --- /dev/null +++ b/pkgs/wow-note/default.nix @@ -0,0 +1,7 @@ +{ lua, runCommand }: +runCommand "wow-note" { buildInputs = [ lua ]; } '' + mkdir -p $out/bin + cat ${./wow_note.lua}> $out/bin/wow-note + chmod +x $out/bin/wow-note + patchShebangs --host $out/bin/wow-note +'' diff --git a/pkgs/wow-note/wow_note.lua b/pkgs/wow-note/wow_note.lua new file mode 100755 index 0000000..51b1e95 --- /dev/null +++ b/pkgs/wow-note/wow_note.lua @@ -0,0 +1,29 @@ +#!/usr/bin/env lua + +if arg[1] == nil then + io.stderr:write("Missing note name argument\n") + os.exit(1) +end + +local data, error = loadfile( + os.getenv("HOME") .. "/GameData/WoW/World of Warcraft/_retail_/WTF/Account/114770488#3/SavedVariables/Notes.lua" +) + +if data == nil then + io.stderr:write(error .. "\n") + os.exit(1) +end + +data() + +for _, note in ipairs(NotesData.notes) do + if note.title == arg[1] then + local hdl = io.popen("wl-copy", "w") + hdl:write(note.text) + hdl:close() + os.exit(0) + end +end + +io.stderr:write("Note not found\n") +os.exit(1)