Macro issue #107
-
I'm setting up some macros and running into an issue. Perhaps what I'm trying to do isn't possible but here's the jist of it... I wrote a zsh script that uses xclip to take copied text and "wrap it" with different characters. This would be useful to me for writing scripts. For example, I can copy a group of text, and the script will quote each line of text. Anyway, the issue I'm running into is running the script directly from lua. I'm not familiar with lua at all but it seems similar to python, which I only just started learning lol. Here's the segment from my lua script. -- place your code here --
debug("Executing: 'single quote macro'")
-- cut selected text
inject_key_with_delay(29, true, 0) -- left ctrl down
inject_key_with_delay(45, true, 5) -- 'x' down
inject_key_with_delay(45, false, 10) -- 'x' up
inject_key_with_delay(29, false, 15) -- left ctrl up
-- run 'text-macro --wrap -q'
-- inject_key_with_delay(56, true, 45) -- left alt down
-- inject_key_with_delay(29, true, 50) -- left ctrl down
-- inject_key_with_delay(125, true, 55) -- left meta down
-- inject_key_with_delay(16, true, 60) -- 'q' down
-- inject_key_with_delay(16, false, 65) -- 'q' up
os.execute("/home/myusername/.local/bin/text-macros --wrap -q")
-- inject_key_with_delay(56, false, 70) -- left alt up
-- inject_key_with_delay(29, false, 70) -- left ctrl up
-- inject_key_with_delay(125, false, 70) -- left meta up
-- paste selected text
inject_key_with_delay(29, true, 200) -- left ctrl down
inject_key_with_delay(47, true, 225) -- 'v' down
inject_key_with_delay(47, false, 230) -- 'v' up
inject_key_with_delay(29, false, 235) -- left ctrl up
I get an error from eruption in my logs PS I tried messing with the timings as well in case I wasn't giving enough time for the command to execute. No luck obviously |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @gimmemabrewski! Thanks for posting this question! I believe you need to provide the correct environment variables to your shell script. Additionally it would be better to not run it as the user the Please replace File #!/bin/bash
USER=`whoami`
USER_ID=`id -u`
DISPLAY=":1"
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/$USER/$USER_ID/bus
export DISPLAY=$DISPLAY
export DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS
/usr/bin/notify-send "Message from Eruption"
You may want to replace the line Please replace result = system("/usr/bin/sudo", {"-u", "user", "/home/user/.local/bin/macro.sh"})
if result ~= 0 then
error("Command execution failed with result: " .. result)
end |
Beta Was this translation helpful? Give feedback.
Hi @gimmemabrewski! Thanks for posting this question!
I believe you need to provide the correct environment variables to your shell script. Additionally it would be better to not run it as the user the
eruption
daemon runs as (root
), but as your user instead.Please replace
USER
,USER_ID
andDISPLAY
with the correct values for your system:File
macro.sh
:You may want to replace the line
/…