<SOLVED>Show mac address of wlan0

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
Fred Barclay
Level 12
Level 12
Posts: 4185
Joined: Sat Sep 13, 2014 11:12 am
Location: USA primarily

<SOLVED>Show mac address of wlan0

Post by Fred Barclay »

How can I show the mac address of my wireless interface, wlan0? I can't seem to track down how to do it online.
I did discover that if I use

Code: Select all

 ${wireless_ap wlan0}
it gives the bssid of the router I'm currently connected to, but that's not really what I'm after.

Thanks!
Fred
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Image
"Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy."
- Albert Einstein
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: Show mac address of wlan0

Post by xenopeek »

This command works for me:

Code: Select all

ip -o link show wlan0 | sed -r 's/^.*link\/ether ([^ ]*) .*$/\1/'
The -o option is to have ip output one line. The MAC address is known as the link/ether address so I extract that with sed.
Image
User avatar
Fred Barclay
Level 12
Level 12
Posts: 4185
Joined: Sat Sep 13, 2014 11:12 am
Location: USA primarily

Re: Show mac address of wlan0

Post by Fred Barclay »

Hey xenopeek! How would I tie that in with conky? I've tried just adding the code, putting it inside of braces, adding a $ to the beginning... but conky displays the string instead of a value for the mac address.
Thanks!
Image
"Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy."
- Albert Einstein
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: Show mac address of wlan0

Post by xenopeek »

I don't know conky. If it is using bash syntax, you would use:

Code: Select all

$(ip -o link show wlan0 | sed -r 's/^.*link\/ether ([^ ]*) .*$/\1/')
Image
User avatar
Fred Barclay
Level 12
Level 12
Posts: 4185
Joined: Sat Sep 13, 2014 11:12 am
Location: USA primarily

Re: Show mac address of wlan0

Post by Fred Barclay »

Didn't show the mac address, only the string of code. :(
Oh well. Thanks anyway!
Image
"Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy."
- Albert Einstein
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: Show mac address of wlan0

Post by xenopeek »

I Googled "conky execute command example" (found https://wiki.gentoo.org/wiki/Conky/Guid ... _variables) and I think on conky you have to do it like this:

Code: Select all

${exec ip -o link show wlan0 | sed -r 's/^.*link\/ether ([^ ]*) .*$/\1/'}
Image
User avatar
mzsade
Level 5
Level 5
Posts: 776
Joined: Sun Jul 19, 2009 4:36 am

Re: Show mac address of wlan0

Post by mzsade »

Thanks, i used that for my eth0 first in the terminal without the ${exec}, then with it in conky and it works perfectly. This is once too often that i've exploited sed without knowing diddley-squat about it. Reading up on it is now among the first things on my procrastinator's to-do list.
This is now prominently displayed in my conky;

Code: Select all

MAC  Addr $alignc${execi 300 ip -o link show eth0 | sed -r 's/^.*link\/ether ([^ ]*) .*$/\1/'}
Public IP $alignc${execi 300 wget -q -O - checkip.dyndns.org | sed -e 's/[^[:digit:]\|.]//g'}
Local  IP $alignc${addr} 
Even though privacy ranks very low on my Internet priorities, just as a point of academic interest, is it wise to display all 3 publicly? What are the risks? I believe the question is relevant to the thread but if you think it should be pursued in a new one, please ignore.

@Fred, Isn't this "Solved" for you yet? :)
Linux User #481272 Reg: 15th Sept., 2008
User avatar
Fred Barclay
Level 12
Level 12
Posts: 4185
Joined: Sat Sep 13, 2014 11:12 am
Location: USA primarily

Re: Show mac address of wlan0

Post by Fred Barclay »

mzsade wrote: @Fred, Isn't this "Solved" for you yet? :)
Sorry, xeno (and mzsade) I meant to mark it as solved later today. Anyhow, it's working quite well. Thanks!
Xenopeek--that link you posted looks quite interesting. I'm going to read up on it. :)
Image
"Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy."
- Albert Einstein
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: <SOLVED>Show mac address of wlan0

Post by xenopeek »

mzsade wrote:This is once too often that i've exploited sed without knowing diddley-squat about it. Reading up on it is now among the first things on my procrastinator's to-do list.
I was in the same place. I haven't found a good online source to truly grasp sed but I got this book and it covers all aspects of sed and is very easy to read (and not too thick :wink:): http://www.sed-book.com/
Image
Locked

Return to “Compiz, Conky, Docks & Widgets”