You are not logged in.
Offline
Nice.
I am currently connected to an ethernet network and only "connected on eth0" is displayed. I would expect to get at least my IP address and probably the default gateway.
Consider also using new VCS PKGBUILD guidelines for your PKGBUILD.
Cedric Girard
Offline
Yeah, I've been super lazy concerning the content of the tooltip, and printed the output of wpa_cli status verbatim (when I detect we are connected on wireless). I guess it would require some parsing, and I could also mix that with some infos from 'ip addr show dev <interface>'. On the other hand, I'd like to keep the whole thing light and readable, and avoid exceeding 100 loc. But if you write a patch, I'll take it happily!
I'll update the PKGBUILD.
Last edited by duquesnc (2013-04-25 15:22:45)
Offline
But if you write a patch, I'll take it happily!
I will have a look. It does not seem too complicated.
Cedric Girard
Offline
I put the entry in .xinitrc. The icon does appear in tint2. It shows that I am disconnected when I do have a connection. How can I fix? Thank you!
Offline
Could you tell me what is the output of the following command?
ip route show
Offline
Ok here it is
$ ip route show
default via 192.168.0.1 dev wlp0s26f7u1 metric 303
192.168.0.0/24 dev wlp0s26f7u1 proto kernel scope link src 192.168.0.101 metric 303
Offline
Great. Now can you try to run:
ping 192.168.0.1
netmon determines if it is connected by trying to ping the gateway. I assumed this method was reliable, but maybe not. Also, can you run
ls /sys/class/net/wlp0s26f7u1
cat /sys/class/net/wlp0s26f7u1/type
Offline
My guess is that the ping command will fail. The two other extra commands are just to check if netmon is guessing the interface type (wireless or wired) correctly.
Offline
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=2.44 ms
cat /sys/class/net/wlp0s26f7u1/type 1
ls /sys/class/net/wlp0s26f7u1
addr_assign_type dev_id ifalias netdev_group speed uevent
addr_len device ifindex operstate statistics wireless
address dormant iflink phy80211 subsystem
broadcast duplex link_mode power tx_queue_len
carrier flags mtu queues type
I apologize I forgot to mention it before, but this is a Archbang system.
If I call it as root from the terminal I get the the red x icon in tint2 but the correct tool tip output.
Last edited by barkbombardier (2013-06-11 21:13:15)
Offline
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
If I call it as root from the terminal I get the the red x icon in tint2 but the correct tool tip output.
Oh, so it is not that netmon is malfunctionning. It's a problem in your icon theme: it misses standard icons. netmon uses 3 icons that are normally always present in a theme. These icons are called "network-wired", "network-wireless" and "network-error". It seems that your theme is missing these icons. Try to install faenza-icon-theme, for example, and change your settings to use this icon theme.
EDIT:
If I call it as root
You mean that if you don't, it incorrectly reports that you are disconnected?
EDIT 2:
By the way, do you confirm that you are connected through a wireless interface?
Last edited by duquesnc (2013-06-11 21:32:48)
Offline
That was it,thanks
Offline
Ok.
As a reminder: there is no reason to run netmon as root, it is not supposed to require root access.
Offline
When runing as user, it brings me to the following traceback:
$ netmon
Failed to connect to non-global ctrl_ifname: (null) error: Permission denied
Traceback (most recent call last):
File "/usr/bin/netmon", line 113, in <module>
MainApp()
File "/usr/bin/netmon", line 76, in __init__
self.update_icon()
File "/usr/bin/netmon", line 107, in update_icon
tooltip = self.get_tooltip(info['interface'], info['connected'])
File "/usr/bin/netmon", line 98, in get_tooltip
res = '\n'.join([res, wpa_status()])
File "/usr/bin/netmon", line 49, in wpa_status
return subprocess.check_output(['wpa_cli', 'status']).strip()
File "/usr/lib/python2.7/subprocess.py", line 575, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['wpa_cli', 'status']' returned non-zero exit status 255
If use kdesu netmon, it works.
What could be the problem with?
Offline
Well it appears that, for some reason, the command 'wpa_cli status' fails when you run it as a user. Normally, this command does not require root access. Maybe you could confirm that by running it command as a user. Then, if the command actually returns an error, it is probably because you did not put yourself in the group wheel or something like that (in that case you should use the gpasswd command to add yourself in the wheel group).
Offline
Hello,
I have ported this little script to use Python 3 and PyQt4, because I found it usefull and I'm using razor-qt as my desktop. It's not finished (I have no wired connection to test), but works for my wireless connection.
#!/usr/bin/env python3
import os
import re
import sys
from subprocess import check_output
from PyQt4 import QtCore, QtGui
ENC = sys.getfilesystemencoding() or 'utf-8'
eth_re = re.compile(r'(inet6? [^ ]*) ', re.I)
def _get_interfaces(exclude_localhost=True):
if exclude_localhost:
return [x for x in os.listdir('/sys/class/net') if x != 'lo']
else:
return os.listdir('/sys/class/net')
def get_default_interface():
"""Returns the interface for the default route."""
ifaces = _get_interfaces()
out = check_output(['ip', 'route', 'list', 'scope', 'global']).decode(ENC)
for line in out.split('\n'):
if line.startswith('default'):
for iface in ifaces:
if ' {0} '.format(iface) in line:
return iface
def check_carrier(iface):
with open(os.path.join('/sys/class/net', iface, 'carrier')) as fp:
return fp.read().strip() == '1'
def get_wireless_status():
return check_output(['wpa_cli', 'status']).decode(ENC).strip()
def get_wired_status(iface):
out = check_output(['ip', 'addr', 'show', 'dev', iface]).decode(ENC)
res = []
for match in eth_re.finditer(out):
res.append(match.group(1))
return '\n'.join(res)
def get_interface_type(iface):
iface_type = 'wired'
iface_dir = os.path.join('/sys/class/net', iface)
_dir = os.listdir(iface_dir)
with open(os.path.join(iface_dir, 'type')) as fp:
_id = fp.read().strip()
if _id == '1' and ('wireless' in _dir or 'phy80211' in _dir):
iface_type = 'wireless'
return iface_type
class TrayIcon(QtGui.QSystemTrayIcon):
def __init__(self, parent=None):
QtGui.QSystemTrayIcon.__init__(self, parent)
self.iface = None
self.iface_type = None
self.setup()
if self.iface is not None:
self.showMessage('Network',
'Connected with {0}.'.format(self.iface))
else:
self.showMessage('Network', 'Not connected.')
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.setup)
self.timer.start(5000)
def setup(self):
self.iface = get_default_interface()
self.iface_type = get_interface_type(self.iface)
if self.iface_type == 'wired':
self.setIcon(QtGui.QIcon.fromTheme('network-wired'))
self.setToolTip(get_wired_status(self.iface))
else:
self.setIcon(QtGui.QIcon.fromTheme('network-wireless'))
self.setToolTip(get_wireless_status())
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
tray = TrayIcon()
tray.show()
sys.exit(app.exec_())
Whitie
Edit: I think the better way is to get all the information from dbus. I try to implement it soon.
Last edited by whitie (2013-08-20 21:23:10)
Offline