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

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

Closed
wants to merge 1 commit into from
Closed

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

wants to merge 1 commit into from

Conversation

jdholtz
Copy link
Contributor

@jdholtz jdholtz commented Mar 30, 2024

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
Copy link
Contributor

lasers commented Mar 31, 2024

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
Copy link
Contributor Author

jdholtz commented Mar 31, 2024

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.

@jdholtz jdholtz closed this Mar 31, 2024
@lasers
Copy link
Contributor

lasers commented Mar 31, 2024

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'
}

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

Successfully merging this pull request may close these issues.

2 participants