浏览代码

refactor scripts | add credits

siduck 3 年之前
父节点
当前提交
5191be0cab

+ 2 - 1
README.md

@@ -82,8 +82,9 @@ sudo make install
 
 # Credits 
 
-- HUGE THANKS to [eProTaLT83](https://www.reddit.com/user/eProTaLT83). I wanted certain features in dwm like tabbar in monocle , tagpreview etc and he implemented my ideas and created patches for me! I   cant even count the number of times he has helped me :v 
+- HUGE THANKS to [eProTaLT83](https://www.reddit.com/user/eProTaLT83). I wanted certain features in dwm like tabbar in monocle , tagpreview etc and he implemented my ideas and created patches for me! I cant even count the number of times he has helped me :v 
 - @fitrh helped with [colorful tag patch](https://github.com/fitrh/dwm/issues/1)
+- [6gk](https://github.com/6gk/fet.sh), eww's pure posix fetch functions taken from here
 
 # Patches
 

+ 15 - 0
eww/scripts/audio

@@ -0,0 +1,15 @@
+#!/bin/sh
+
+headvol() {
+  amixer sget Headphone | grep 'Left:' | cut -d\  -f7 | tr -d '[%]'
+}
+
+mastervol() {
+  amixer get Master | awk '$0~/%/{print $4}' | tr -d '[%]'
+}
+
+micvol() {
+  amixer sget Mic | grep 'Left:' | cut -d\  -f7 | tr -d '[%]'
+}
+
+"$@"

+ 0 - 2
eww/scripts/audio/headvol

@@ -1,2 +0,0 @@
-#!/bin/sh
-amixer sget Headphone | grep 'Left:' | cut -d\  -f7 | tr -d '[%]'

+ 0 - 2
eww/scripts/audio/mastervol

@@ -1,2 +0,0 @@
-#!/bin/sh
-amixer get Master | awk '$0~/%/{print $4}' | tr -d '[%]'

+ 0 - 2
eww/scripts/audio/micvol

@@ -1,2 +0,0 @@
-#!/bin/sh
-amixer sget Mic | grep 'Left:' | cut -d\  -f7 | tr -d '[%]'

+ 32 - 0
eww/scripts/fetch

@@ -0,0 +1,32 @@
+#!/bin/bash
+
+os() {
+  source /etc/os-release && echo $PRETTY_NAME
+}
+
+wm() {
+  wm=$XDG_CURRENT_DESKTOP
+  [ "$wm" ] || wm=$DESKTOP_SESSION
+
+  ## WM/DE
+  [ ! "$wm" ] &&
+    # loop over all processes and check the binary name
+    for i in /proc/*/comm; do
+      read -r c <"$i"
+      case $c in
+      *bar*) ;;
+      awesome | xmonad* | qtile | sway | i3 | [bfo]*box | *wm*)
+        wm=${c%%-*}
+        break
+        ;;
+      esac
+    done
+
+  echo $wm
+}
+
+shell() {
+  basename $SHELL
+}
+
+"$@"

+ 0 - 3
eww/scripts/fetch/os

@@ -1,3 +0,0 @@
-#!/bin/bash
-
-source /etc/os-release && echo $PRETTY_NAME

+ 0 - 1
eww/scripts/fetch/shell

@@ -1 +0,0 @@
-basename $SHELL

+ 0 - 3
eww/scripts/fetch/wm

@@ -1,3 +0,0 @@
-#!/bin/bash
-
-xprop -id $(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}') -notype -f _NET_WM_NAME 8t | grep "WM_NAME" | cut -f2 -d \"

+ 0 - 1
eww/scripts/pkg/pkgs

@@ -1 +0,0 @@
-xbps-query -l | wc -l

+ 0 - 9
eww/scripts/pkg/updates

@@ -1,9 +0,0 @@
-#!/bin/bash
-
-updates=$(xbps-install -S -un | cut -d' ' -f2 | sort | uniq -c | xargs)
-
-if [ -z "$updates" ]; then
-    echo "Fully Updated"
-else
-    echo " $updates""s"
-fi

+ 44 - 0
eww/scripts/system

@@ -0,0 +1,44 @@
+#!/bin/sh
+
+pkgCount() {
+  xbps-query -l | wc -l
+}
+
+pkgUpdates() {
+  updates=$(xbps-install -S -un | cut -d' ' -f2 | sort | uniq -c | xargs)
+
+  if [ -z "$updates" ]; then
+    echo "Fully Updated"
+  else
+    echo " $updates""s"
+  fi
+}
+
+battery() {
+  cat /sys/class/power_supply/BAT1/capacity
+}
+
+cpu() {
+  grep -o "^[^ ]*" /proc/loadavg
+}
+
+disk() {
+  df -hl | awk '/^\/dev\/sd[ab]/ { sum+=$5 } END { print sum }'
+}
+
+ram() {
+  printf "%.0f\n" $(free -m | grep Mem | awk '{print ($3/$2)*100}')
+}
+
+backlight() {
+  printf "%.0f\n" $(xbacklight -get)
+}
+
+wifi() {
+  case "$(cat /sys/class/net/wl*/operstate 2>/dev/null)" in
+  up) printf "󰤨" ;;
+  down) printf "󰤭" ;;
+  esac
+}
+
+"$@"

+ 0 - 3
eww/scripts/system/battery

@@ -1,3 +0,0 @@
-#!/bin/bash
-
-cat /sys/class/power_supply/BAT1/capacity

+ 0 - 1
eww/scripts/system/cpu

@@ -1 +0,0 @@
-grep -o "^[^ ]*" /proc/loadavg

+ 0 - 1
eww/scripts/system/disk

@@ -1 +0,0 @@
-df -hl | awk '/^\/dev\/sd[ab]/ { sum+=$5 } END { print sum }'

+ 0 - 1
eww/scripts/system/pkgs

@@ -1 +0,0 @@
-xbps-query -l | wc -l

+ 0 - 2
eww/scripts/system/ram

@@ -1,2 +0,0 @@
-#!/bin/sh
-printf "%.0f\n" $(free -m | grep Mem | awk '{print ($3/$2)*100}')

+ 14 - 14
eww/var.yuck

@@ -1,15 +1,15 @@
 ; system i.e for progress bars
 (defpoll cpu :interval "1s"
-    "scripts/system/cpu")
+    "scripts/system cpu")
 
 (defpoll ram :interval "1s"
-    "scripts/system/ram")
+    "scripts/system ram")
 
 (defpoll disk :interval "1s"
-    "scripts/system/disk")
+    "scripts/system disk")
 
 (defpoll battery :interval "1s"
-    "scripts/system/battery")
+    "scripts/system battery")
 
 ; date time
 (defpoll time :interval "1s"
@@ -22,37 +22,37 @@
 
 ; audio 
 (defpoll master_vol :interval "1s"
-  "scripts/audio/mastervol")
+  "scripts/audio mastervol")
 
 (defpoll head_vol :interval "1s"
-  "scripts/audio/headvol")
+  "scripts/audio headvol")
 
 (defpoll mic_vol :interval "1h"
-  "scripts/audio/micvol")
+  "scripts/audio micvol")
 
 ; backlight 
 (defpoll brightness :interval "1s"
-  "scripts/backlight")
+  "scripts/system backlight")
 
 ; pkg related 
 (defpoll updates :interval "1s"
-    "scripts/pkg/updates")
+    "scripts/system pkgUpdates")
 
 (defpoll pkgs :interval "1s"
-    "scripts/pkg/pkgs")
+    "scripts/system pkgCount")
 
 ; btns
 
 ; wifi iwdgtk btn 
 (defpoll wifi :interval "1s"
-    "scripts/wifi")
+    "scripts/system wifi")
 
 ;fetch 
 (defpoll os :interval '10000s'
-  'scripts/fetch/os')
+  'scripts/fetch os')
 
 (defpoll shell :interval '100000s'
-  'scripts/fetch/shell')
+  'scripts/fetch shell')
 
 (defpoll wm :interval '100000s'
-  'scripts/fetch/wm')
+  'scripts/fetch wm')