Mac style copy/paste on Void Linux
Another quick post that may be useful to somebody else. I’ve been working at UKG for about 4 months now. In my work I use a Mac laptop. I’ve tried my best to unify my configurations between my personal Linux system and the Mac dev machine provided by UKG to reduce headaches when having to switch from professional to personal projects. This even went as far as trying to configure OpenBox to be more like the MacOS desktop environment (HA a big failed endeavour). While I ultimately found peace with differences in desktop environments, there was another thing I found very hard to deal with.
Differences in Keybindings!!#
I made a lot of changes and compromises when setting up my Mac system and configuring my personal machine.
One notable change was swapping my main modkey for dwm
from Meta
to Alt
to better mimic the Mac setup.
I tried doing the reverse of swapping Option
and Cmd
in Mac, but that was a really rough time.
I’ve also tried to keep many other keybindings, associated with things like moving windows or changing workspaces, consistent.
One thing that was causing endless headaches was copy and paste.
I don’t know the exact count of times I’ve pressed Alt+C
or Alt+V
at home in vain, but it is certainly significant.
As a result I spent some time to figure out how to do this.
Final Solution#
I configure my dwm
specific keybindings in my config.h
, but for everything else I use sxhkd
.
This allows me to more easily reload keybindings instead of having to cycle dwm
and lose all of my window placements.
I highly recommend this kind of setup.
My final solution, added to my sxhkdrc
is:
alt + c
xclip -selection primary -o | xclip -selection clipboard -i
alt + v
sh -c 'xclip -selection clipboard -o | xclip -selection primary -i && xdotool click 2'
I tried several other ways, most notable being just trying to send Ctrl+C
when I pressed Alt+C
, but nothing else worked.
How it works#
A quick description of how it works:
Alt+C
takes the primary selection and copies it to the clipboardAlt+V
takes the clipboard and copies it to the primary selection and then emulates a middle mouse button click to paste.
I was hoping for a more elegant solution but ¯_(ツ)_/¯