Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to run shell commands? #64

Open
WeissP opened this issue Mar 16, 2020 · 6 comments
Open

Is there a way to run shell commands? #64

WeissP opened this issue Mar 16, 2020 · 6 comments

Comments

@WeissP
Copy link

WeissP commented Mar 16, 2020

I want to run some scripts with xkeysnail but don't know how.

@Lenbok
Copy link
Contributor

Lenbok commented Mar 17, 2020

According to the example config, there is a 'launch' command, so you can do something like this:

define_keymap(None, {
    K("print"): launch(["gnome-screenshot", "--interactive"]),
    K("Super-p"): launch(["gnome-screenshot", "--interactive"]),
}, "Global shortcuts")

I had never tried it before, but since I've been wanting to try converting my xbindkeys config to such a launch system, so I gave it a go. It works, but since xkeysnail is run via sudo, the subsequent gnome-screenshot is running as root, which is less than ideal. Does @mooz use the launch capability?

@singletS
Copy link

Would runuser work here?

@Lenbok
Copy link
Contributor

Lenbok commented Mar 18, 2020

I played with runuser, but it's difficult to get environment variables passed through (e.g. I need variables to disable client-side decorations etc). Instead, I've set up udev rules so that xkeysnail can run as the current user, without sudo.

First create a new group to which we allow access to the input stuff, and add this group to your user:

sudo groupadd -f uinput
sudo gpasswd -a $USER uinput

Create new udev rule granting access:

cat <<EOF | sudo tee /etc/udev/rules.d/70-xkeysnail.rules
KERNEL=="uinput", GROUP="uinput", MODE="0660", OPTIONS+="static_node=uinput"
KERNEL=="event[0-9]*", GROUP="uinput", MODE="0660"
EOF

Reboot. xkeysnail should now run OK without sudo. The launch examples I listed above now work fine.

@rbreaves
Copy link
Contributor

I think runuser would probably work with something like env DISPLAY=:0 /sbin/runuser -l username -c "/path/to/program" would be my guess.

This is going to be useful though as I am thinking about implementing something to help inspect the clipboard before just copying the contents into a terminal without warning or a previewing assuming it is multiline or has carriage returns in it.

@joshgoebel
Copy link

joshgoebel commented May 25, 2022

Sorry, wrong thread.

@joshgoebel
Copy link

I have an issue on my fork exploring how this might be done properly and securely.... it's not super difficult if someone wanted to implement it and test it out... (on top of my fork or even on top of the last xkeysnail 0.4.0). I don't believe any of the new things I've implemented in my fork are necessary.

joshgoebel/keyszer#44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants