merged usm path fix with upstream
This commit is contained in:
commit
1745c3e033
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
*swp
|
*swp
|
||||||
|
test/
|
||||||
|
5
bright
5
bright
@ -3,9 +3,10 @@
|
|||||||
if [ ! -z "$1" ]
|
if [ ! -z "$1" ]
|
||||||
then
|
then
|
||||||
screens="`xrandr | grep ' connected' | awk '{print $1}'`"
|
screens="`xrandr | grep ' connected' | awk '{print $1}'`"
|
||||||
|
percentage=`echo "scale=2;" "$1/100" | bc -l`
|
||||||
for s in $screens; do
|
for s in $screens; do
|
||||||
xrandr --output "$s" --brightness "0.7"
|
xrandr --output "$s" --brightness "0$percentage"
|
||||||
echo xrandr --output "$s" --brightness "0.7"
|
echo xrandr --output "$s" --brightness "0$percentage"
|
||||||
done
|
done
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
4
distro
4
distro
@ -35,7 +35,7 @@ o88888"888"88o. "8888"".88 .oo888oo..
|
|||||||
# Now some diagnostic shit idk man
|
# Now some diagnostic shit idk man
|
||||||
#echo "Packages installed: ${red}`dpkg --get-selections | grep -v deinstall | wc -l`${nc}
|
#echo "Packages installed: ${red}`dpkg --get-selections | grep -v deinstall | wc -l`${nc}
|
||||||
echo "Distro: ${green}`uname -v | awk '{print $3}'`${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 =|:^)"
|
echo "=|:^) Art: https://www.asciiart.eu/plants/flowers =|:^)"
|
||||||
sleep 1
|
|
||||||
|
|
||||||
|
@ -1,5 +1,22 @@
|
|||||||
|
# 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:
|
stat:
|
||||||
gcc -o statline status.c -O2 -s -lX11
|
gcc $(MFLAGS) -o $(output) status.c $(flags)
|
||||||
|
|
||||||
|
run:
|
||||||
|
./statline
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f statline
|
rm -f statline
|
||||||
|
@ -4,12 +4,11 @@
|
|||||||
// This version mainly aims to ve a visual overhaul of both code and output over barM
|
// This version mainly aims to ve a visual overhaul of both code and output over barM
|
||||||
// Dependancies: cat grep awk
|
// Dependancies: cat grep awk
|
||||||
|
|
||||||
// Define these however you like
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
@ -18,8 +17,10 @@
|
|||||||
#define BASIC_MSG "/comfy/ o clock | "
|
#define BASIC_MSG "/comfy/ o clock | "
|
||||||
#define TIME_FORMAT "%I:%M%p - %d %b %Y"
|
#define TIME_FORMAT "%I:%M%p - %d %b %Y"
|
||||||
|
|
||||||
|
// Time in seconds
|
||||||
#define TIME_DELAY 5
|
#define TIME_DELAY 5
|
||||||
#define MAXSTR 1024
|
#define MAXSTR 1024
|
||||||
|
#define SMALL_BUF 32
|
||||||
|
|
||||||
#define MEM_BREAD_SIZE 32
|
#define MEM_BREAD_SIZE 32
|
||||||
#define STD_IO
|
#define STD_IO
|
||||||
@ -61,11 +62,69 @@ ram_usage(void)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LAPTOP
|
||||||
|
#define BATTERY_STATUS_BUFFER 50
|
||||||
|
#define REDUCER 1000
|
||||||
|
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)/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);
|
||||||
|
curr = atoi(buf)/REDUCER;
|
||||||
|
}
|
||||||
|
|
||||||
|
float level = (float)curr / (float)total;
|
||||||
|
snprintf(buf, BATTERY_STATUS_BUFFER, "Battery: %.2f%%", level*100);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
#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*
|
static char*
|
||||||
cpu_usage(void)
|
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
|
static void
|
||||||
XSetRoot(char* name)
|
XSetRoot(char* name)
|
||||||
@ -90,6 +149,12 @@ main(void)
|
|||||||
static char* (*func_table[])(void) = {
|
static char* (*func_table[])(void) = {
|
||||||
ram_usage,
|
ram_usage,
|
||||||
date_time,
|
date_time,
|
||||||
|
#ifdef LAPTOP
|
||||||
|
battery_percentage,
|
||||||
|
#endif
|
||||||
|
#ifdef CPU_USAGE
|
||||||
|
cpu_usage,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
char stat_output[MAXSTR];
|
char stat_output[MAXSTR];
|
||||||
|
5
newbga
5
newbga
@ -10,6 +10,7 @@ base="/home/shockrah/Pictures/VPapes"
|
|||||||
# Pic two random video papes
|
# Pic two random video papes
|
||||||
pape1=`ls "${HOME}/Pictures/VPapes" | shuf | head -n 1`
|
pape1=`ls "${HOME}/Pictures/VPapes" | shuf | head -n 1`
|
||||||
pape2=`ls "${HOME}/Pictures/VPapes" | shuf | head -n 1`
|
pape2=`ls "${HOME}/Pictures/VPapes" | shuf | head -n 1`
|
||||||
|
echo
|
||||||
while "$pape1" = "$pape2"
|
while "$pape1" = "$pape2"
|
||||||
do
|
do
|
||||||
pape2=`ls "${HOME}/Pictures/VPapes" | shuf | head -n 1`
|
pape2=`ls "${HOME}/Pictures/VPapes" | shuf | head -n 1`
|
||||||
@ -29,6 +30,7 @@ mpv="mpv --wid WID --no-config --keepaspect=no --loop \
|
|||||||
# First monitor
|
# First monitor
|
||||||
xwinwrap -g 1920x1080 -ni -fdt -sh rectangle -un -b -nf -ov -- $mpv "$base/$pape1" & > /dev/null 2>&1 &
|
xwinwrap -g 1920x1080 -ni -fdt -sh rectangle -un -b -nf -ov -- $mpv "$base/$pape1" & > /dev/null 2>&1 &
|
||||||
echo $! > ${HOME}/.cache/mpvbg.pid
|
echo $! > ${HOME}/.cache/mpvbg.pid
|
||||||
|
echo "$pape1" > $HOME/.cache/newbga_img
|
||||||
|
|
||||||
# Quick check if we even have a second monitor at all
|
# Quick check if we even have a second monitor at all
|
||||||
c=`xrandr | grep ' connected' | wc -l`
|
c=`xrandr | grep ' connected' | wc -l`
|
||||||
@ -39,5 +41,4 @@ fi
|
|||||||
# Second monitor
|
# Second monitor
|
||||||
xwinwrap -g 1920x1080+1920+0 -ni -fdt -sh rectangle -un -b -nf -ov -- $mpv "$base/$pape2" & > /dev/null 2>&1 &
|
xwinwrap -g 1920x1080+1920+0 -ni -fdt -sh rectangle -un -b -nf -ov -- $mpv "$base/$pape2" & > /dev/null 2>&1 &
|
||||||
echo $! >> ${HOME}/.cache/mpvbg.pid
|
echo $! >> ${HOME}/.cache/mpvbg.pid
|
||||||
|
echo "$pape1" >> $HOME/.cache/newbga_img
|
||||||
|
|
||||||
|
18
readme.md
18
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?
|
## 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
|
## TODO
|
||||||
|
|
||||||
Scale 0-5
|
Scale 1 - 3
|
||||||
|
|
||||||
* 0 = High priority
|
* 0 = High priority
|
||||||
* 5 = Low priority
|
* 5 = Low priority
|
||||||
|
|
||||||
|
Breakdown of scale via
|
||||||
|
|
||||||
usbm 0
|
```
|
||||||
|
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
|
||||||
|
|
||||||
* Actually finishing the userland mount script
|
|
||||||
* Remove necessity for root
|
* Remove necessity for root
|
||||||
|
|
||||||
|
Wifi 2
|
||||||
|
|
||||||
|
* Get some kind of security for network configs
|
||||||
|
14
usm
14
usm
@ -1,15 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
mntpnt="/mnt"
|
||||||
|
|
||||||
# pick out the drive but not sda because thats the main drive
|
# pick out the drive but not sda because thats the main drive
|
||||||
choice=`lsblk -lp | \
|
choice=`lsblk -lp | \
|
||||||
grep 'disk ' | \
|
grep -e 'part $' -e "part /mnt/*"| \
|
||||||
awk '{print $1, $4}' | \
|
awk '{print $1, $4}' | \
|
||||||
dmenu -i -p 'Drive to (un)mount'`
|
dmenu -i -p 'Drive to (un)mount'`
|
||||||
if [ -z "$choice" ]; then exit; fi
|
if [ -z "$choice" ]; then exit; fi
|
||||||
|
|
||||||
# Check if it's already mounted / something was even picked
|
|
||||||
dev=`echo $choice | awk '{print $1}'`
|
dev=`echo $choice | awk '{print $1}'`
|
||||||
name="`basename $dev`"
|
name="`basename $dev`"
|
||||||
if [ -z "$dev" ]; then exit; fi
|
if [ -z "$dev" ]; then exit; fi
|
||||||
|
|
||||||
|
# Check if it's already mounted / something was even picked
|
||||||
if grep -qs "$dev" /proc/mounts;
|
if grep -qs "$dev" /proc/mounts;
|
||||||
then
|
then
|
||||||
# unmount the drive
|
# unmount the drive
|
||||||
@ -20,8 +23,9 @@ then
|
|||||||
then
|
then
|
||||||
rm -d ~/.mounts/
|
rm -d ~/.mounts/
|
||||||
fi
|
fi
|
||||||
|
umount $dev
|
||||||
|
rm -d "$mntpnt/$name"
|
||||||
else
|
else
|
||||||
# Finally we can mount the thing
|
mkdir -p "$mntpnt/$name"
|
||||||
mkdir -p "~/.mounts/$name"
|
mount "$dev" "$mntpnt/$name"
|
||||||
mount "$dev" "~/.mounts/$name"
|
|
||||||
fi
|
fi
|
||||||
|
98
wifi
Executable file
98
wifi
Executable file
@ -0,0 +1,98 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# TODO: rid ourselves of plaintext configs which can have sensitive network keys
|
||||||
|
|
||||||
|
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 ]
|
||||||
|
then
|
||||||
|
echo 'Must be ran as root'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
__write_config_personal() {
|
||||||
|
printf "network={
|
||||||
|
ssid=\"$2\"
|
||||||
|
psk=\"$3\"
|
||||||
|
}\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" ]
|
||||||
|
then
|
||||||
|
kill "`pgrep wpa_supplicant`"
|
||||||
|
dhclient -r
|
||||||
|
else
|
||||||
|
echo 'Not killing anything'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__connect_config() {
|
||||||
|
if [ -z "$debug_kill" ]
|
||||||
|
then
|
||||||
|
__kill_old
|
||||||
|
wpa_supplicant -B -i wlp1s0 -c "$1"
|
||||||
|
dhclient wlp1s0
|
||||||
|
else
|
||||||
|
echo Not connecting to anything
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_old_config() {
|
||||||
|
name="`ls $cfg_loc | dmenu -i -p 'Name of config to remove'`"
|
||||||
|
rm -f "$cfg_loc/$name"
|
||||||
|
}
|
||||||
|
|
||||||
|
reconnect_old_config() {
|
||||||
|
name="`ls $cfg_loc | dmenu -i -p 'Choose config to connect with'`"
|
||||||
|
if [ ! -z "$name" ]
|
||||||
|
then
|
||||||
|
__connect_config "$cfg_loc/$name"
|
||||||
|
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_personal "$name" "$ssid" "$psk"
|
||||||
|
;;
|
||||||
|
*Enterprise)
|
||||||
|
ssid="`echo '' | dmenu -p 'SSID'`"
|
||||||
|
identity="`echo '' | dmenu -p 'Identity'`"
|
||||||
|
psk="`echo '' | dmenu -p 'Passkey'`"
|
||||||
|
__write_config_enterprise $ssid $identity $psk $name
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
option=`printf "Remove\nConnect\nNew\nDiconnect\n" | dmenu -i -p 'Options:'`
|
||||||
|
case $option in
|
||||||
|
New) create_new_config;;
|
||||||
|
Remove) remove_old_config;;
|
||||||
|
Connect) reconnect_old_config;;
|
||||||
|
Disconnect) __kill_old;;
|
||||||
|
esac
|
Loading…
Reference in New Issue
Block a user