i3status-rust icon indicating copy to clipboard operation
i3status-rust copied to clipboard

Trimming the length of the IP address

Open stratosgear opened this issue 3 years ago • 5 comments

Sorry if I missed that, but I would like to trim my IP address from 192.168.1.101 -> 101.

I guess this does not have to apply to the net block only, but it should be a string formatting capability...?

Does something like this exist...? I would be happy if I could even just trim to any fixed length from the end too, like: "1.101"

stratosgear avatar Sep 28 '21 10:09 stratosgear

@MaxVerevkin, @GladOSkar I had a quick look through #1304 again but I don't think this one has been discussed yet. I guess it's kinda like max_width but from the opposite direction.

ammgws avatar Nov 07 '21 00:11 ammgws

I guess it's kinda like max_width but from the opposite direction.

Yes, pretty much. Any suggestions on which modifier to add?

MaxVerevkin avatar Nov 07 '21 07:11 MaxVerevkin

Maybe consider ip4 and ip6 separate data types from num/str and have max_width be in octets/hextets from the right respectively?

Then again there's probably also a valid use case for only displaying the subnet part. TBH this is too niche of a use case for the general formatter IMO.

GladOSkar avatar Nov 07 '21 09:11 GladOSkar

Maybe consider ip4 and ip6 separate data types from num/str and have max_width be in octets/hextets from the right respectively?

Yeah, that's probably better.

MaxVerevkin avatar Nov 07 '21 10:11 MaxVerevkin

A note on this one in case someone implements it. Please don't assume it's always going to be right to left - for example for external IP addresses you probably care about the left bytes more than you do about the right ones.

cfsmp3 avatar Dec 11 '21 22:12 cfsmp3