From d83b3e02c46f943c6bb4520161e8f8e893f279d3 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Mon, 26 Aug 2019 13:56:25 -0700 Subject: [PATCH 01/20] removedd fluff --- yes | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 yes diff --git a/yes b/yes deleted file mode 100644 index 2d57af2..0000000 --- a/yes +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ls $HOME/Books/ | dmenu -l 15 | zathura From 94afcfb80fe7991ceb570b4f981bb69e2797bf1d Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Mon, 26 Aug 2019 17:27:17 -0700 Subject: [PATCH 02/20] new todo for dwm-stat --- readme.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/readme.md b/readme.md index 45fc018..0e37dbd 100644 --- a/readme.md +++ b/readme.md @@ -20,3 +20,8 @@ usbm 0 * Actually finishing the userland mount script * Remove necessity for root + +dwm-stat 4 + +* cpu usage monitor +* better make script From 2e206acca7d4fe2071f21e529702627208599510 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 28 Aug 2019 17:34:42 -0700 Subject: [PATCH 03/20] fixed usb mounting script but it still requires root perms --- usm | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/usm b/usm index 8066f69..4199eb3 100755 --- a/usm +++ b/usm @@ -1,27 +1,24 @@ #!/bin/sh +mntpnt="/mnt" + # pick out the drive but not sda because thats the main drive choice=`lsblk -lp | \ - grep 'disk ' | \ + grep -e 'part $' -e "part /mnt/*"| \ awk '{print $1, $4}' | \ dmenu -i -p 'Drive to (un)mount'` if [ -z "$choice" ]; then exit; fi -# Check if it's already mounted / something was even picked dev=`echo $choice | awk '{print $1}'` name="`basename $dev`" if [ -z "$dev" ]; then exit; fi + +# Check if it's already mounted / something was even picked if grep -qs "$dev" /proc/mounts; then # unmount the drive - umount "~/.mounts/$name" - rm -d "~/.mounts/$name" - # check if we still need the .mounts directory or nah - if [ "`ls ~/.mounts/`" ] - then - rm -d ~/.mounts/ - fi + umount $dev + rm -d "$mntpnt/$name" else - # Finally we can mount the thing - mkdir -p "~/.mounts/$name" - mount "$dev" "~/.mounts/$name" + mkdir -p "$mntpnt/$name" + mount "$dev" "$mntpnt/$name" fi From 102ee41c0d4f4a35a101fb30ed4eda7e104a153c Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 28 Aug 2019 17:40:59 -0700 Subject: [PATCH 04/20] removed todo last one is rather minor --- readme.md | 3 +-- usm | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 0e37dbd..e79ba1e 100644 --- a/readme.md +++ b/readme.md @@ -16,9 +16,8 @@ Scale 0-5 * 5 = Low priority -usbm 0 +usbm 2 -* Actually finishing the userland mount script * Remove necessity for root dwm-stat 4 diff --git a/usm b/usm index 4199eb3..2f6c33d 100755 --- a/usm +++ b/usm @@ -15,7 +15,6 @@ if [ -z "$dev" ]; then exit; fi # Check if it's already mounted / something was even picked if grep -qs "$dev" /proc/mounts; then - # unmount the drive umount $dev rm -d "$mntpnt/$name" else From c000ee9ef78d7a9b19500a2218fea5cabc31c0ef Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Thu, 29 Aug 2019 20:43:39 -0700 Subject: [PATCH 05/20] wifi connectivity script --- wifi | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100755 wifi diff --git a/wifi b/wifi new file mode 100755 index 0000000..73c8a23 --- /dev/null +++ b/wifi @@ -0,0 +1,78 @@ +#!/bin/sh + +# TODO: rid ourselves of plaintext configs which can have sensitive network keys + +cfg_loc="$HOME/.config/wifi-configs/" +iface="wlp1s0" + +debug_kill='on' +__write_config() { +printf "network={ + ssid=\"$2\" + psk=\"$3\" +}\n" # > "$cfg_loc/$1" +} + +__kill_old() { + if [ ! -z "$debug_kill" ] + then + kill `pgrep wpa` + dhclient -r + else + echo 'Not killing anything' + fi +} + +_reconnect_config() { + __kill_old + if [ ! -z "$debug_kill" ] + then + __kill_old + else + echo 'No restart' + fi +} + +remove_old_config() { + name="`echo '' | dmenu -i -p 'Name of config to remove(This will disconnect you)'`" + rm -f "$cfg_loc/$name" + __kill_old +} + +create_new_config() { + name="`echo '' | dmenu -i -p 'Name of new config'`" + type="`printf "WPA2 Personal\nWPA2 Enterprise" | dmenu -i -p 'Connection Type'`" + + case $type in + *Personal) + ssid="`echo '' | dmenu -p 'SSID'`" + psk="`echo '' | dmenu -p 'Passkey'`" + __write_config "$HOME/.config//$name" "$ssid" "$psk" + con="`printf "Yes\nNo" | dmenu -i -p 'Connect with new config?'`" + if [ "$con" = "Yes" ] + then + _reconnect_config $con + fi + ;; + *Enterprise) + echo 'Not yet implemented' | dmenu -p 'SSID' + exit + ;; + esac +} + +reconnect_old_config() { + name="`ls $cfg_loc | dmenu -i -p 'Choose config to connect with'`" + if [ -f $name ] + then + rm -f "$cfg_loc/$name" + __kill_old + fi +} + +option=`printf "Remove\nReconnect\nNew\n" | dmenu -i` +case $option in + New) create_new_config;; + Remove) remove_old_config;; + Reconnect) reconnect_old_config;; +esac From 4547825e0336011fc79e5f0a281e79d36c5416c7 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Fri, 30 Aug 2019 12:52:43 -0700 Subject: [PATCH 06/20] fixed some """"issues"""", really just made behavior follow expectations --- wifi | 76 +++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/wifi b/wifi index 73c8a23..3911e04 100755 --- a/wifi +++ b/wifi @@ -5,16 +5,38 @@ cfg_loc="$HOME/.config/wifi-configs/" iface="wlp1s0" -debug_kill='on' -__write_config() { +# wpa_supplicant and dhclient are only exposed to root by default +if [ "`id -u`" -ne 0 ] +then + echo 'Must be ran as root' + exit 1 +fi +# Only activating this for testing the menu tbh +debug_kill= + +__write_config_personal() { printf "network={ ssid=\"$2\" psk=\"$3\" -}\n" # > "$cfg_loc/$1" +}\n" > "$cfg_loc/$1" } +__write_config_enterprise() { +printf "network={ + ssid=\"$1\" + scan_ssid=1 + key_mgmt=WPA-EAP + identity=\"$2\" + password=\"$3\" + eap=PEAP + phase1=\"peaplabel=0\" + phase2=\"auth=MSCHAPV2\" +}" > "$cfg_loc/$4" +} + + __kill_old() { - if [ ! -z "$debug_kill" ] + if [ -z "$debug_kill" ] then kill `pgrep wpa` dhclient -r @@ -23,56 +45,56 @@ __kill_old() { fi } -_reconnect_config() { - __kill_old - if [ ! -z "$debug_kill" ] +__connect_config() { + if [ -z "$debug_kill" ] then __kill_old + wpa_supplicant -B -i wlp1s0 -c /etc/wpa_supplicant.conf -D wext + dhclient wlp1s0 else echo 'No restart' fi } remove_old_config() { - name="`echo '' | dmenu -i -p 'Name of config to remove(This will disconnect you)'`" + name="`echo '' | dmenu -i -p 'Name of config to remove'`" rm -f "$cfg_loc/$name" - __kill_old +} + +reconnect_old_config() { + name="`ls $cfg_loc | dmenu -i -p 'Choose config to connect with'`" + if [ ! -z "$name" ] + then + __kill_old + __connect_config + fi } create_new_config() { name="`echo '' | dmenu -i -p 'Name of new config'`" type="`printf "WPA2 Personal\nWPA2 Enterprise" | dmenu -i -p 'Connection Type'`" + mkdir -p $cfg_loc case $type in *Personal) ssid="`echo '' | dmenu -p 'SSID'`" psk="`echo '' | dmenu -p 'Passkey'`" - __write_config "$HOME/.config//$name" "$ssid" "$psk" - con="`printf "Yes\nNo" | dmenu -i -p 'Connect with new config?'`" - if [ "$con" = "Yes" ] - then - _reconnect_config $con - fi + __write_config_personal "$cfg_loc/$name" "$ssid" "$psk" ;; *Enterprise) - echo 'Not yet implemented' | dmenu -p 'SSID' - exit + ssid="`echo '' | dmenu -p 'SSID'`" + identity="`echo '' | dmenu -p 'Identity'`" + psk="`echo '' | dmenu -p 'Passkey'`" + __write_config_enterprise $ssid $identity $psk $name ;; esac } -reconnect_old_config() { - name="`ls $cfg_loc | dmenu -i -p 'Choose config to connect with'`" - if [ -f $name ] - then - rm -f "$cfg_loc/$name" - __kill_old - fi -} -option=`printf "Remove\nReconnect\nNew\n" | dmenu -i` +option=`printf "Remove\nConnect\nNew\nDiconnect\n" | dmenu -i` case $option in New) create_new_config;; Remove) remove_old_config;; - Reconnect) reconnect_old_config;; + Connect) reconnect_old_config;; + Disconnect) __kill_old;; esac From 1212d4968bb8deaf31020dd56d04d4f5732add37 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Fri, 30 Aug 2019 13:14:00 -0700 Subject: [PATCH 07/20] jank as hell but it works lmao --- wifi | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/wifi b/wifi index 3911e04..b5ec646 100755 --- a/wifi +++ b/wifi @@ -2,7 +2,7 @@ # TODO: rid ourselves of plaintext configs which can have sensitive network keys -cfg_loc="$HOME/.config/wifi-configs/" +cfg_loc="/home/shockrah/.config/wifi-configs/" iface="wlp1s0" # wpa_supplicant and dhclient are only exposed to root by default @@ -38,7 +38,9 @@ printf "network={ __kill_old() { if [ -z "$debug_kill" ] then - kill `pgrep wpa` + echo killing old process + kill "`pgrep wpa_supplicant`" + echo releasing leases dhclient -r else echo 'Not killing anything' @@ -49,10 +51,13 @@ __connect_config() { if [ -z "$debug_kill" ] then __kill_old - wpa_supplicant -B -i wlp1s0 -c /etc/wpa_supplicant.conf -D wext + echo Seriously this is going to take a minute + echo Setting up wpa_supplicant + wpa_supplicant -B -i wlp1s0 -c "$1" + echo Attempting dhclient dhclient wlp1s0 else - echo 'No restart' + echo Not connecting to anything fi } @@ -65,8 +70,7 @@ reconnect_old_config() { name="`ls $cfg_loc | dmenu -i -p 'Choose config to connect with'`" if [ ! -z "$name" ] then - __kill_old - __connect_config + __connect_config "$cfg_loc/$name" fi } From 331633d41e2d6bf2d267f866df61e8a3b3aea768 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Fri, 30 Aug 2019 14:08:19 -0700 Subject: [PATCH 08/20] updated makefile to support building for laptops --- dwm-stat/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dwm-stat/Makefile b/dwm-stat/Makefile index 87d0b39..64bdfe1 100644 --- a/dwm-stat/Makefile +++ b/dwm-stat/Makefile @@ -1,5 +1,10 @@ +flags=-O2 -s -lX11 +output=statline stat: - gcc -o statline status.c -O2 -s -lX11 + gcc -o $(output) status.c $(flags) + +laptop: + gcc -D LAPTOP status.c -o $(output) status.c $(flags) clean: rm -f statline From 51e16193fb7ec9d8a089e972f8e4020a02502d38 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Fri, 30 Aug 2019 16:30:58 -0700 Subject: [PATCH 09/20] fixed parameters given to __write_config_personal from create_new_config --- wifi | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/wifi b/wifi index b5ec646..73c8db2 100755 --- a/wifi +++ b/wifi @@ -4,6 +4,7 @@ cfg_loc="/home/shockrah/.config/wifi-configs/" iface="wlp1s0" +debug_kill= # wpa_supplicant and dhclient are only exposed to root by default if [ "`id -u`" -ne 0 ] @@ -11,8 +12,6 @@ then echo 'Must be ran as root' exit 1 fi -# Only activating this for testing the menu tbh -debug_kill= __write_config_personal() { printf "network={ @@ -83,7 +82,7 @@ create_new_config() { *Personal) ssid="`echo '' | dmenu -p 'SSID'`" psk="`echo '' | dmenu -p 'Passkey'`" - __write_config_personal "$cfg_loc/$name" "$ssid" "$psk" + __write_config_personal "$name" "$ssid" "$psk" ;; *Enterprise) ssid="`echo '' | dmenu -p 'SSID'`" @@ -95,7 +94,7 @@ create_new_config() { } -option=`printf "Remove\nConnect\nNew\nDiconnect\n" | dmenu -i` +option=`printf "Remove\nConnect\nNew\nDiconnect\n" | dmenu -i -p 'Options:'` case $option in New) create_new_config;; Remove) remove_old_config;; From 7153462b2aec51f0c4ca5645cdec6fbd46004d82 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Fri, 30 Aug 2019 16:32:11 -0700 Subject: [PATCH 10/20] removed fluff echo's --- wifi | 4 ---- 1 file changed, 4 deletions(-) diff --git a/wifi b/wifi index 73c8db2..a7ebb87 100755 --- a/wifi +++ b/wifi @@ -37,9 +37,7 @@ printf "network={ __kill_old() { if [ -z "$debug_kill" ] then - echo killing old process kill "`pgrep wpa_supplicant`" - echo releasing leases dhclient -r else echo 'Not killing anything' @@ -51,9 +49,7 @@ __connect_config() { then __kill_old echo Seriously this is going to take a minute - echo Setting up wpa_supplicant wpa_supplicant -B -i wlp1s0 -c "$1" - echo Attempting dhclient dhclient wlp1s0 else echo Not connecting to anything From 89263c87eda6ece59626af50ee7a032dcdb77332 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Sun, 1 Sep 2019 19:02:04 -0700 Subject: [PATCH 11/20] fixed parameter ingest on bright and added more info to distro script --- bright | 5 +++-- distro | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bright b/bright index 11c1ea5..7eedea8 100755 --- a/bright +++ b/bright @@ -3,9 +3,10 @@ if [ ! -z "$1" ] then screens="`xrandr | grep ' connected' | awk '{print $1}'`" + percentage=`echo "scale=2;" "$1/100" | bc -l` for s in $screens; do - xrandr --output "$s" --brightness "0.7" - echo xrandr --output "$s" --brightness "0.7" + xrandr --output "$s" --brightness "0$percentage" + echo xrandr --output "$s" --brightness "0$percentage" done exit 0 fi diff --git a/distro b/distro index fa64336..cbcd144 100755 --- a/distro +++ b/distro @@ -35,7 +35,7 @@ o88888"888"88o. "8888"".88 .oo888oo.. # Now some diagnostic shit idk man #echo "Packages installed: ${red}`dpkg --get-selections | grep -v deinstall | wc -l`${nc} echo "Distro: ${green}`uname -v | awk '{print $3}'`${nc} -Kernel: ${white}`uname -o`${nc}" +Kernel: ${red}`uname -r` ${nc} +System: ${white}`uname -o`(duh)${nc}" echo "=|:^) Art: https://www.asciiart.eu/plants/flowers =|:^)" -sleep 1 From 0707bf28db6c91517db4e080a0cead6b692639db Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Mon, 2 Sep 2019 02:50:31 -0700 Subject: [PATCH 12/20] support for laptop battery percentage in statline --- dwm-stat/status.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/dwm-stat/status.c b/dwm-stat/status.c index 97cc212..2f86f58 100644 --- a/dwm-stat/status.c +++ b/dwm-stat/status.c @@ -4,12 +4,11 @@ // This version mainly aims to ve a visual overhaul of both code and output over barM // Dependancies: cat grep awk -// Define these however you like #include #include #include -#include #include +#include #include #include #include @@ -61,6 +60,34 @@ ram_usage(void) return buf; } +#ifdef LAPTOP +#define BATTERY_STATUS_BUFFER 50 +static char* +battery_percentage(void) +{ + unsigned long total, curr; + static char buf[BATTERY_STATUS_BUFFER]; + + FILE* file_max = fopen("/sys/class/power_supply/BAT0/energy_full","r"); + if(file_max) { + fgets(buf, BATTERY_STATUS_BUFFER, file_max); + fclose(file_max); + total = atoi(buf); + } + + FILE* file_curr = fopen("/sys/class/power_supply/BAT0/energy_now", "r"); + if(file_curr) { + fgets(buf, BATTERY_STATUS_BUFFER, file_max); + fclose(file_curr); + total = atoi(buf); + } + + snprintf(buf, BATTERY_STATUS_BUFFER, "Battery: %.2f", (float)(curr/total)); + return buf; +} +#endif + + static char* cpu_usage(void) { @@ -90,6 +117,9 @@ main(void) static char* (*func_table[])(void) = { ram_usage, date_time, +#ifdef LAPTOP + battery_percentage, +#endif }; char stat_output[MAXSTR]; From 6847da88595e7634fabbc67675113b70e6bda4f3 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Mon, 2 Sep 2019 02:50:57 -0700 Subject: [PATCH 13/20] respective makefile --- dwm-stat/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwm-stat/Makefile b/dwm-stat/Makefile index 64bdfe1..b2b99d8 100644 --- a/dwm-stat/Makefile +++ b/dwm-stat/Makefile @@ -4,7 +4,7 @@ stat: gcc -o $(output) status.c $(flags) laptop: - gcc -D LAPTOP status.c -o $(output) status.c $(flags) + gcc -D LAPTOP=1 status.c -o $(output) status.c $(flags) clean: rm -f statline From 217889d082af4d1e82c8187f9b8dbabb93ef0227 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Mon, 2 Sep 2019 02:54:20 -0700 Subject: [PATCH 14/20] oh my that was dumb --- dwm-stat/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dwm-stat/Makefile b/dwm-stat/Makefile index b2b99d8..579b7bd 100644 --- a/dwm-stat/Makefile +++ b/dwm-stat/Makefile @@ -4,7 +4,8 @@ stat: gcc -o $(output) status.c $(flags) laptop: - gcc -D LAPTOP=1 status.c -o $(output) status.c $(flags) + # compiling with LAPTOP=1 + gcc -D LAPTOP=1 status.c -o $(output) $(flags) clean: rm -f statline From 8f5152206b1323f85a38fb1d28f99d4e13492944 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Mon, 2 Sep 2019 03:04:32 -0700 Subject: [PATCH 15/20] finalized support for optional laptop battery level --- dwm-stat/Makefile | 3 +++ dwm-stat/status.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dwm-stat/Makefile b/dwm-stat/Makefile index 579b7bd..c6e0efe 100644 --- a/dwm-stat/Makefile +++ b/dwm-stat/Makefile @@ -7,6 +7,9 @@ laptop: # compiling with LAPTOP=1 gcc -D LAPTOP=1 status.c -o $(output) $(flags) +run: + ./statline + clean: rm -f statline diff --git a/dwm-stat/status.c b/dwm-stat/status.c index 2f86f58..1955384 100644 --- a/dwm-stat/status.c +++ b/dwm-stat/status.c @@ -17,6 +17,7 @@ #define BASIC_MSG "/comfy/ o clock | " #define TIME_FORMAT "%I:%M%p - %d %b %Y" +// Time in seconds #define TIME_DELAY 5 #define MAXSTR 1024 @@ -62,6 +63,7 @@ ram_usage(void) #ifdef LAPTOP #define BATTERY_STATUS_BUFFER 50 +#define REDUCER 1000 static char* battery_percentage(void) { @@ -72,17 +74,18 @@ battery_percentage(void) if(file_max) { fgets(buf, BATTERY_STATUS_BUFFER, file_max); fclose(file_max); - total = atoi(buf); + total = atoi(buf)/REDUCER; } FILE* file_curr = fopen("/sys/class/power_supply/BAT0/energy_now", "r"); if(file_curr) { fgets(buf, BATTERY_STATUS_BUFFER, file_max); fclose(file_curr); - total = atoi(buf); + curr = atoi(buf)/REDUCER; } - snprintf(buf, BATTERY_STATUS_BUFFER, "Battery: %.2f", (float)(curr/total)); + float level = (float)curr / (float)total; + snprintf(buf, BATTERY_STATUS_BUFFER, "Battery: %.2f%%", level*100); return buf; } #endif From c3917e34b1c8b761eb8515b3992400643bc08212 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Tue, 3 Sep 2019 11:39:59 -0700 Subject: [PATCH 16/20] added cpu usage to statline makefile now has configurable options --- dwm-stat/Makefile | 18 +++++++++++++----- dwm-stat/status.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/dwm-stat/Makefile b/dwm-stat/Makefile index c6e0efe..a5108d9 100644 --- a/dwm-stat/Makefile +++ b/dwm-stat/Makefile @@ -1,11 +1,19 @@ +# Here are the configuraable options +# LAPTOP : enable batter level +# CPU_USAGE : CPU usage in percentage +# DEBUG : for fixing issues + +# NOTE: the -D is needed for gcc +# MFLAGS= -D MY_OPTION -D ANOTHER_OPT ... +MFLAGS=-D LAPTOP -D CPU_USAGE + + flags=-O2 -s -lX11 output=statline -stat: - gcc -o $(output) status.c $(flags) -laptop: - # compiling with LAPTOP=1 - gcc -D LAPTOP=1 status.c -o $(output) $(flags) + +stat: + gcc $(MFLAGS) -o $(output) status.c $(flags) run: ./statline diff --git a/dwm-stat/status.c b/dwm-stat/status.c index 1955384..fff87dc 100644 --- a/dwm-stat/status.c +++ b/dwm-stat/status.c @@ -20,6 +20,7 @@ // Time in seconds #define TIME_DELAY 5 #define MAXSTR 1024 +#define SMALL_BUF 32 #define MEM_BREAD_SIZE 32 #define STD_IO @@ -91,11 +92,39 @@ battery_percentage(void) #endif +#ifdef CPU_USAGE +// stat(2) -> +#define CPU_PROC_BASE +#define TOTAL "head /proc/stat -n 1 | cut -c 6- | sed 's/ /\\+/g' | bc" +#define IDLE "head /proc/stat -n 1 | cut -c 6- | awk '{print $4}'" static char* cpu_usage(void) { - return "CPU Usage Placeholder"; + // NOTE: not accounting for the query so this may be somewhat off by some metric + // Grabbing the total usage + FILE* query_p; + static char buf[SMALL_BUF]; + unsigned total, idle; + // get the total time + query_p = popen(TOTAL, "r"); + fgets(buf, sizeof(buf)-1, query_p); + total = atoi(buf); + pclose(query_p); + + // get the idle time + query_p = popen(IDLE, "r"); + fgets(buf, sizeof(buf)-1, query_p); + idle = atoi(buf); + pclose(query_p); + + double usage = 1.00 - ((double)idle / (double)total); +#ifdef DEBUG + printf("IDLE/TOTAL = %.02f\n", usage); +#endif + sprintf(buf, "CPU: %.02f % ", usage); + return buf; } +#endif static void XSetRoot(char* name) @@ -122,6 +151,9 @@ main(void) date_time, #ifdef LAPTOP battery_percentage, +#endif +#ifdef CPU_USAGE + cpu_usage, #endif }; From cdf93ec9f769652a964e9ca3d78d4714ab37f58c Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Tue, 3 Sep 2019 11:40:56 -0700 Subject: [PATCH 17/20] finsihed optional cpu usage feature --- readme.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/readme.md b/readme.md index e79ba1e..26ba4fb 100644 --- a/readme.md +++ b/readme.md @@ -20,7 +20,3 @@ usbm 2 * Remove necessity for root -dwm-stat 4 - -* cpu usage monitor -* better make script From 56967bb9edbc5c68e00105be20690821204b31ed Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 4 Sep 2019 12:05:03 -0700 Subject: [PATCH 18/20] fixed removal(forgot to pipe in configs --- wifi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wifi b/wifi index a7ebb87..4104a56 100755 --- a/wifi +++ b/wifi @@ -57,7 +57,7 @@ __connect_config() { } remove_old_config() { - name="`echo '' | dmenu -i -p 'Name of config to remove'`" + name="`ls $cfg_loc | dmenu -i -p 'Name of config to remove'`" rm -f "$cfg_loc/$name" } From e61bf60c1a1ee544a0dda858dc510e3ea079e68e Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 4 Sep 2019 13:02:55 -0700 Subject: [PATCH 19/20] updated docs --- readme.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 26ba4fb..27b852f 100644 --- a/readme.md +++ b/readme.md @@ -6,17 +6,27 @@ Right now most of them are filled with basisms but thats slowly changing overtim ## I have a cool script too can I contribute it here? -Of course! [Submit a merge request](https://docs.gitlab.com/ee/gitlab-basics/add-merge-request.html) or just email the file/file to my email `alejandros714@protonmail.com`. +Of course! [Submit a merge request](https://docs.gitlab.com/ee/gitlab-basics/add-merge-request.html) or just email the file(s) to my email `alejandros714@protonmail.com`. ## TODO -Scale 0-5 +Scale 1 - 3 * 0 = High priority * 5 = Low priority +Breakdown of scale via -usbm 2 +``` +1: Something is broken to the point of not being usable +2: Issue which affects safety or usually has something to do with really awkward usage +3: Minor pain that doesn't really hurt but is nice to have gone +``` + +usbm 3 * Remove necessity for root +Wifi 2 + +* Get some kind of security for network configs From fd9e31e4ce33571e8c34400df53a506f69d27264 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 4 Sep 2019 16:47:59 -0700 Subject: [PATCH 20/20] removed fluff and adding test directory --- .gitignore | 1 + wifi | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d9568ca..6d315a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *swp +test/ diff --git a/wifi b/wifi index 4104a56..fafba7e 100755 --- a/wifi +++ b/wifi @@ -48,7 +48,6 @@ __connect_config() { if [ -z "$debug_kill" ] then __kill_old - echo Seriously this is going to take a minute wpa_supplicant -B -i wlp1s0 -c "$1" dhclient wlp1s0 else