Browse Source

initial commit

bmallred 10 years ago
commit
12aca5e73d
2 changed files with 27 additions and 0 deletions
  1. 5 0
      README.md
  2. 22 0
      i3status-update-network

+ 5 - 0
README.md

@ -0,0 +1,5 @@
1
i3status-update-network
2
=======================
3
4
Simple ZSH script to update the i3status configuration file with the current network
5
devices found on the machine.

+ 22 - 0
i3status-update-network

@ -0,0 +1,22 @@
1
#!/bin/zsh
2
3
# Declare some variables
4
local config=$HOME'/.config/i3status/config'
5
local ethernet=''
6
local wireless=''
7
8
# Find devices
9
for dev in $(ls /sys/class/net); do
10
    if [[ $dev[0,1] == "e" ]]; then
11
        ethernet=$dev
12
    elif [[ $dev[0,1] == "w" ]]; then
13
        wireless=$dev
14
    fi
15
done
16
17
# Search the configuration file and update it appropriately
18
sed -e 's/^order\s*+=\s*\"ethernet.*/order += \"ethernet '$ethernet'\"/g' \
19
    -e 's/^order\s*+=\s*\"wireless.*/order += \"wireless '$wireless'\"/g' \
20
    -e 's/^ethernet.*/ethernet '$ethernet' {/g' \
21
    -e 's/^wireless.*/wireless '$wireless' {/g' \
22
    -i $config