ultrabug / py3status

py3status is an extensible i3status wrapper written in python
https://ultrabug.github.io/py3status/
BSD 3-Clause "New" or "Revised" License
893 stars 261 forks source link

vpn_status: Add a button to copy your IPv4 address of the connected VPN(s) #2244

Closed jdholtz closed 6 months ago

jdholtz commented 6 months ago

This PR adds the ability to configure a button (default left mouse click) to copy the IP address of the currently connected VPN (if multiple are connected, whichever one you click on) to the clipboard.

I'm not tied to the name button_copy_ipv4 and open to suggestions. Also, I can add a button to copy the ipv6 address separately or copy that as a fallback if the ipv4 address doesn't exist.

This feature was inspired by Kali Linux's new release, which had this feature added to their Xfce desktop.

lasers commented 6 months ago

Can you use this? https://github.com/ultrabug/py3status/blob/master/docs/user-guide/configuration.md#module-data-and-on_click-commands

I don't know how your format looks like, but if it have its own composite, then you could do this.

vpn_status   {
    on_click 1 = 'exec echo $OUTPUT_PART | xclip -i'
}

EDIT: I dislike the idea that we should add copy_to buttons to all or some modules and would suggest users to try and use this approach... Can output to a script that would grep anything after ip word or such... because maybe one day you will stop using this feature.

There is also nothing stopping you from using this in your personal modules folder which should be located in ~/.config/py3status/modules.

jdholtz commented 6 months ago

Can you use this?

Wow, I didn't know this exists. That works perfectly. Will close this then as it is already built-in (and less complicated).

There is also nothing stopping you from using this in your personal modules folder which should be located in ~/.config/py3status/modules.

That's what I've been doing for the past couple of months, but thought I'd add it for anyone else that would find it helpful. I'll just resort to the on-click commands though as that is a nice feature.

lasers commented 6 months ago

https://www.shellhacks.com/regex-find-ip-addresses-file-grep/

# untested
vpn_status   {
    on_click 1 = 'exec echo $OUTPUT | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | xclip -i'
}