<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=3986&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / dwm statusbar bash script]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=3986</link>
		<description><![CDATA[The most recent posts in dwm statusbar bash script.]]></description>
		<lastBuildDate>Thu, 15 Apr 2021 17:00:12 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: dwm statusbar bash script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=29150#p29150</link>
			<description><![CDATA[<div class="quotebox"><cite>dice wrote:</cite><blockquote><div><p>Thanks Ogis, glad it worked for you. <img src="https://dev1galaxy.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p></div></blockquote></div><p>Yes. This script works great in Debian 10. I&#039;ll try it tomorrow on Devuan 3.1 <img src="https://dev1galaxy.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (Ogis1975)]]></author>
			<pubDate>Thu, 15 Apr 2021 17:00:12 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=29150#p29150</guid>
		</item>
		<item>
			<title><![CDATA[Re: dwm statusbar bash script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=29135#p29135</link>
			<description><![CDATA[<p>Thanks Ogis, glad it worked for you. <img src="https://dev1galaxy.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (dice)]]></author>
			<pubDate>Thu, 15 Apr 2021 13:42:30 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=29135#p29135</guid>
		</item>
		<item>
			<title><![CDATA[Re: dwm statusbar bash script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=29134#p29134</link>
			<description><![CDATA[<div class="quotebox"><cite>dice wrote:</cite><blockquote><div><p>What i like about this script is ive found a way to maintain timed loops inside the while loop itself using let. I would love any feedback to see if this is a viable script free from errors.</p></div></blockquote></div><p>Thank you for this script. Works flawlessly and very well !</p><p><a href="https://ibb.co/R3tx940" rel="nofollow"><span class="postimg"><img src="https://i.ibb.co/Cb4kzs7/2021-04-15-160329-1920x1080-scrot.png" alt="2021-04-15-160329-1920x1080-scrot.png" /></span></a></p>]]></description>
			<author><![CDATA[dummy@example.com (Ogis1975)]]></author>
			<pubDate>Thu, 15 Apr 2021 13:11:46 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=29134#p29134</guid>
		</item>
		<item>
			<title><![CDATA[Re: dwm statusbar bash script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=26411#p26411</link>
			<description><![CDATA[<div class="quotebox"><cite>dice wrote:</cite><blockquote><div><p>if wlan0 is connected first and then usb0, the default is always going to be wlan0 and vice versa, would that be true?</p></div></blockquote></div><p>Yes, I think you&#039;re right.</p><p>Another alternative:</p><div class="codebox"><pre><code>ip link | awk &#039;/UP /{print $2}&#039;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (Head_on_a_Stick)]]></author>
			<pubDate>Fri, 25 Dec 2020 15:45:09 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=26411#p26411</guid>
		</item>
		<item>
			<title><![CDATA[Re: dwm statusbar bash script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=26405#p26405</link>
			<description><![CDATA[<div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><div class="quotebox"><cite>dice wrote:</cite><blockquote><div><p>ip l shows ifaces even if they are down whereas ifconfig and netstat does not. So this would make the script only output multiple if ip was used.</p></div></blockquote></div><p>Ah yes, of course. But ifconfig shows all interfaces that are up, which includes interfaces which are not connected.</p><p>How about this:</p><div class="codebox"><pre><code>ip r | awk &#039;/^default/{print $5}&#039;</code></pre></div><p>^ That shows the name of the interface currently connected.</p></div></blockquote></div><p>I suppose the default gateway is the way to go, so if wlan0 is connected first and then usb0, the default is always going to be wlan0 and vice versa, would that be true?. I wonder how conky does the gw_iface object though.</p><p>In regards to ifconfig, atleast in my case on devuan beowulf, if wlan0 is not connected it wont show up in ifconfig, only lo. where ip l all interfaces are shown regardless if they are up or down.</p>]]></description>
			<author><![CDATA[dummy@example.com (dice)]]></author>
			<pubDate>Fri, 25 Dec 2020 10:21:38 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=26405#p26405</guid>
		</item>
		<item>
			<title><![CDATA[Re: dwm statusbar bash script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=26404#p26404</link>
			<description><![CDATA[<div class="quotebox"><cite>dice wrote:</cite><blockquote><div><p>ip l shows ifaces even if they are down whereas ifconfig and netstat does not. So this would make the script only output multiple if ip was used.</p></div></blockquote></div><p>Ah yes, of course. But ifconfig shows all interfaces that are up, which includes interfaces which are not connected.</p><p>How about this:</p><div class="codebox"><pre><code>ip r | awk &#039;/^default/{print $5}&#039;</code></pre></div><p>^ That shows the name of the interface currently connected.</p>]]></description>
			<author><![CDATA[dummy@example.com (Head_on_a_Stick)]]></author>
			<pubDate>Fri, 25 Dec 2020 08:48:14 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=26404#p26404</guid>
		</item>
		<item>
			<title><![CDATA[Re: dwm statusbar bash script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=26400#p26400</link>
			<description><![CDATA[<p>head on a stick, I could use ip but have to tack on sort like so.</p><div class="codebox"><pre><code>ip route | grep -ow &#039;wlan0\|usb0&#039; | sort -u
usb0
wlan0</code></pre></div><p>otherwise without sort</p><div class="codebox"><pre><code>ip route | grep -ow &#039;wlan0\|usb0&#039;
wlan0
wlan0
usb0</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (dice)]]></author>
			<pubDate>Fri, 25 Dec 2020 01:36:54 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=26400#p26400</guid>
		</item>
		<item>
			<title><![CDATA[Re: dwm statusbar bash script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=26399#p26399</link>
			<description><![CDATA[<div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><div class="quotebox"><cite>dice wrote:</cite><blockquote><div><p>If it is old and deprecated why is it still in the kernel?</p></div></blockquote></div><p>It&#039;s not in the kernel, ifconfig is a(n obsolete) userspace utility.</p><p>And anyway what&#039;s wrong with</p><div class="codebox"><pre><code>a=$(ip l | grep -ow &quot;wlan0\|usb0&quot;)</code></pre></div><p>Off topic for this thread but you should check out <a href="https://tools.suckless.org/slstatus/" rel="nofollow">slstatus</a> — pure C ftw!</p></div></blockquote></div><p>In regards to why is it in the kernel, i should have referenced the answer i got from stackoverflow. I know it is part of the net-tools package so i was confused about this quote:</p><div class="quotebox"><blockquote><div><p>That said, ifconfig shouldn&#039;t be used at all on Linux either; it hasn&#039;t been maintained by the upstream kernel team for well over a decade now</p></div></blockquote></div><p>In regards to ip, i have some issues with ip l , the difference being that ip l shows ifaces even if they are down whereas ifconfig and netstat does not. So this would make the script only output multiple if ip was used.</p><p>Here is ip l on my machine with usb0 and wlan0, with only wlan0 up.</p><div class="codebox"><pre><code>ifconfig
lo: flags=73&lt;UP,LOOPBACK,RUNNING&gt;
wlan0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;</code></pre></div><div class="codebox"><pre><code>netstat -i
Kernel Interface table
Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
lo       65536        0      0      0 0             0      0      0      0 LRU
wlan0     1500      810      0      0 0           724      0      0      0 BMRU</code></pre></div><div class="codebox"><pre><code>ip l
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
2: eth0: &lt;BROADCAST,MULTICAST&gt; mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
3: wlan0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
4: usb0: &lt;BROADCAST,MULTICAST&gt; mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000</code></pre></div><p>I have used slstatus in the past, i may revert back to it again, although this endeavor was just to see if i could create shell scripts to pipe to dwm statusbar instead, which i have accomplished.</p>]]></description>
			<author><![CDATA[dummy@example.com (dice)]]></author>
			<pubDate>Fri, 25 Dec 2020 01:00:12 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=26399#p26399</guid>
		</item>
		<item>
			<title><![CDATA[Re: dwm statusbar bash script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=26396#p26396</link>
			<description><![CDATA[<p>I&#039;d echo the vote for slstatus.... to my small mind it is by far and away the best option.</p>]]></description>
			<author><![CDATA[dummy@example.com (manyroads)]]></author>
			<pubDate>Thu, 24 Dec 2020 18:30:16 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=26396#p26396</guid>
		</item>
		<item>
			<title><![CDATA[Re: dwm statusbar bash script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=26395#p26395</link>
			<description><![CDATA[<div class="quotebox"><cite>dice wrote:</cite><blockquote><div><p>If it is old and deprecated why is it still in the kernel?</p></div></blockquote></div><p>It&#039;s not in the kernel, ifconfig is a(n obsolete) userspace utility.</p><p>And anyway what&#039;s wrong with</p><div class="codebox"><pre><code>a=$(ip l | grep -ow &quot;wlan0\|usb0&quot;)</code></pre></div><p>Off topic for this thread but you should check out <a href="https://tools.suckless.org/slstatus/" rel="nofollow">slstatus</a> — pure C ftw!</p>]]></description>
			<author><![CDATA[dummy@example.com (Head_on_a_Stick)]]></author>
			<pubDate>Thu, 24 Dec 2020 15:57:18 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=26395#p26395</guid>
		</item>
		<item>
			<title><![CDATA[Re: dwm statusbar bash script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=26388#p26388</link>
			<description><![CDATA[<p>created a network iface script for this statusbar script. This kind of similar to how conky does it with -</p><div class="quotebox"><blockquote><div><p>gw_iface Displays the default route&#039;s interface or &quot;multiple&quot;/&quot;none&quot; accordingly.</p></div></blockquote></div><p>I was told over at stackoverflow i shouldnt be using ifconfig for something as simple as this, which i think is ridiculous, if i wanted to do fancy stuff with the networks i would use iproute2 but for this, not needed. If it is old and deprecated why is it still in the kernel?</p><p>This will print on my statusbar as follows,</p><ul><li><p>If usb net connected = usb0</p></li></ul><ul><li><p>If wlan0 connected = wlan0</p></li></ul><ul><li><p>If both usb and wlan0 connected =multiple</p></li></ul><ul><li><p>If no network = not connected</p></li></ul><div class="codebox"><pre><code>#!/usr/bin/env bash

a=$(ifconfig | grep -ow &quot;wlan0\|usb0&quot;)
b=$&#039;wlan0\nusb0&#039;
c=&quot;%printf &#039;$b&#039;&quot;

if      [[ &quot;$a&quot; = &quot;wlan0&quot; ]] ; then
        printf &quot;wlan0&quot;

elif    [[ &quot;$a&quot; = &quot;usb0&quot; ]] ; then
        printf &quot;usb0&quot;

elif    [[ &quot;$a&quot; =~ [&quot;$c&quot;] ]] ; then
        printf &quot;multiple&quot;

else
        printf &quot;not connected&quot;
fi</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (dice)]]></author>
			<pubDate>Thu, 24 Dec 2020 10:27:24 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=26388#p26388</guid>
		</item>
		<item>
			<title><![CDATA[dwm statusbar bash script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=26122#p26122</link>
			<description><![CDATA[<p>Managed to hack this together today from various sources, if you use it you would have to play around with the bash command functions.</p><p>What i like about this script is ive found a way to maintain timed loops inside the while loop itself using let. I would love any feedback to see if this is a viable script free from errors.</p><div class="codebox"><pre class="vscroll"><code>#!/bin/bash

get_cpu (){
	printf &quot;Cpu:&quot;
	top -bn1 | awk &#039;NR==3 {print $2}&#039;
	
}

get_disk (){
	printf &quot;| Disk:&quot;
	df -h | awk &#039;NR==4 { print $3&quot; / &quot;$2}&#039;
}

get_mem (){
	printf &quot;| Mem:&quot;
	free -h | awk &#039;NR==2 {print $3&quot; / &quot;$2}&#039;
}

get_temp (){
	printf &quot;| Temps:&quot;
	sensors | awk &#039;/Core/ { printf substr($3,2,2)&quot;°C &quot; }&#039;
}

get_time (){
	printf &quot;| Time:&quot;
	date +&quot;%R&quot;
}

let loop=0
while true; do
   if [[ $loop%60 -eq 0 ]]; then
      Time=$(get_time)
   fi
   
   if [[ $loop%300 -eq 0 ]]; then
      Disk=$(get_disk)
      let loop=0  #this prevents an eventual overflow
   fi
   
   if [[ $loop%8 -eq 0 ]]; then
      Temp=$(get_temp)
   fi
   
   if [[ $loop%3 -eq 0 ]]; then
      Mem=$(get_mem)
   fi
      if [[ $loop%2 -eq 0 ]]; then
      Cpu=$(get_cpu)
   fi
   
   xsetroot -name &quot;$Cpu $Temp $Disk $Mem $Time&quot;
   let loop=$loop+1
   sleep 1
   
done</code></pre></div><p>Update: ran this script through shell check, interesting diff.<br /><a href="https://www.shellcheck.net/" rel="nofollow">https://www.shellcheck.net/</a></p><div class="codebox"><pre class="vscroll"><code>#!/bin/bash

get_cpu (){
	printf &quot;Cpu:&quot;
	top -bn1 | awk &#039;NR==3 {print $2}&#039;
	
}

get_disk (){
	printf &quot;| Disk:&quot;
	df -h | awk &#039;NR==4 { print $3&quot; / &quot;$2}&#039;
}

get_mem (){
	printf &quot;| Mem:&quot;
	free -h | awk &#039;NR==2 {print $3&quot; / &quot;$2}&#039;
}

get_temp (){
	printf &quot;| Temps:&quot;
	sensors | awk &#039;/Core/ { printf substr($3,2,2)&quot;°C &quot; }&#039;
}

get_time (){
	printf &quot;| Time:&quot;
	date +&quot;%R&quot;
}

(( loop=0 ))
while true; do
   if [[ $loop%60 -eq 0 ]]; then
      Time=$(get_time)
   fi
   
   if [[ $loop%300 -eq 0 ]]; then
      Disk=$(get_disk)
      (( loop=0 ))  #this prevents an eventual overflow
   fi
   
   if [[ $loop%8 -eq 0 ]]; then
      Temp=$(get_temp)
   fi
   
   if [[ $loop%3 -eq 0 ]]; then
      Mem=$(get_mem)
   fi
      if [[ $loop%2 -eq 0 ]]; then
      Cpu=$(get_cpu)
   fi
   
   xsetroot -name &quot;$Cpu $Temp $Disk $Mem $Time&quot;
   (( loop=loop+1 ))
   sleep 1
   
done</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (dice)]]></author>
			<pubDate>Sun, 06 Dec 2020 12:41:13 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=26122#p26122</guid>
		</item>
	</channel>
</rss>
