Newcircuit 1c8db4401779333389b774086d6390f160bbb49078a0eda577b43dcf5018a77f

Ashley Whetter's Blog

[programming, linux] ++ [stuff]

Social inside twitter icon ee809e0d7c5b2294b7d548e7223909c678d76c5484045ae68ecb7c559cd7fade Social inside google icon dbbc88b746b52525f1e1bd5e2bf44152b2713fb976f7e68b903c2d13e9fbd160 Octocat 1fcbe3003defcb5ee415b3a7aa989bbc724ccf3c446436e848c27437901c6ca2 Social inside rss icon ff8ccbbb13f265afbe3cadba03c838cdbcad75b6f223a7937eab3ee35afc933d Social inside linkedin icon 5f3acefcb096b75afe32a0e0b3d90d1f2c1b374049eb8c1996203225e1ae34ba

netctl Notifications

Using netctl's hooks it's actually quite easy to get notified when netctl-auto or netctl-ifplugd connects or disconnects from a network. Put the following in a file in /etc/netctl/hooks/, change the wireless interface and the username to your own, and make the file executable.

#!/bin/bash

function send_notification {
	su -c "DISPLAY=:0 notify-send \"$1\" --icon=network-$2" ashley
}

if [[ "$INTERFACE" == "wlp4s0" ]]
then
	case "$ACTION" in
		"CONNECT")
			send_notification "Connected to $SSID" wireless
		;;
		"DISCONNECT")
			send_notification "Disconnected from $SSID" wireless
		;;
	esac
else
	case "$IFPLUGD_CURRENT" in
		"up")
			send_notification "Connected to $1" wired
		;;
		"down")
			send_notification "Disconnected from $1" wired
		;;
	esac
fi

Categories: None