Merge branch 'master' of gitlab.com:shockrah/shell-scripts
This commit is contained in:
commit
6f4f7ec39d
@ -1,14 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# In case you've ever needed to setup
|
|
||||||
|
|
||||||
output=$(xrandr|grep ' connected'|awk '{print $1}' | \
|
|
||||||
dmenu -i -p 'Device to attach')
|
|
||||||
[ -z "$output" ] && exit 0
|
|
||||||
|
|
||||||
# Now we pick out where this goes
|
|
||||||
side=$(printf 'left-of\nright-of\nabove\nbelow' | \
|
|
||||||
dmenu -i -p 'Side')
|
|
||||||
[ -z "$side" ] && exit 0
|
|
||||||
|
|
||||||
# Just echo for demonstrative purposes
|
|
||||||
echo "xrandr --output $output --auto --$side eDP-1"
|
|
7
bread
7
bread
@ -1,9 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
book=$(ls $HOME/Books/ | dmenu -i -l 15)
|
book=`ls $HOME/Books/ | dmenu -i -l 15`
|
||||||
if [ -z "$book" ]
|
if [ ! -z "$book" ]
|
||||||
then
|
then
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
zathura "$HOME/Books/$book"
|
zathura "$HOME/Books/$book"
|
||||||
fi
|
fi
|
||||||
#zathura "$HOME/Books/$book"
|
|
||||||
|
27
bright
27
bright
@ -1,6 +1,23 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Script to siimply change the brightness
|
# this part is only used for startup scripts mainly
|
||||||
level=$(echo "$(seq 1 100)" | dmenu -i -p 'Brightnesss from 1-100')
|
if [ ! -z "$1" ]
|
||||||
percentage=$(echo "$level/100" | bc -l | head -c 4)
|
then
|
||||||
[ -z "$percentage" ] && exit 0
|
screens="`xrandr | grep ' connected' | awk '{print $1}'`"
|
||||||
xrandr --output eDP-1 --brightness $percentage
|
for s in $screens; do
|
||||||
|
xrandr --output "$s" --brightness "0.7"
|
||||||
|
echo xrandr --output "$s" --brightness "0.7"
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Changes brightness through dmenu (because i like my eyes)
|
||||||
|
level=`seq 1 100 | dmenu -i -p 'Brightnesss from 1-100'`
|
||||||
|
if [ -z "$level" ]; then exit; fi
|
||||||
|
|
||||||
|
percentage=`echo "scale=2;" "$level/100" | bc -l`
|
||||||
|
if [ -z "$percentage" ]; then exit; fi
|
||||||
|
|
||||||
|
screens="`xrandr | grep ' connected' | awk '{print $1}'`"
|
||||||
|
for scr in $screens;do
|
||||||
|
xrandr --output "$scr" --brightness $percentage
|
||||||
|
done
|
||||||
|
8
bruh
Executable file
8
bruh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# This is only here because my xserver is rarted
|
||||||
|
# in other words i setup my own rice every login by hand :(
|
||||||
|
newbg
|
||||||
|
bright 60
|
||||||
|
compton -b
|
||||||
|
|
||||||
|
|
41
distro
Executable file
41
distro
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Wanna look cool in desktop threads? here you go
|
||||||
|
|
||||||
|
red='\033[1;31m'
|
||||||
|
green='\033[0;32m'
|
||||||
|
white='\033[1;37m'
|
||||||
|
nc='\033[0m'
|
||||||
|
clear
|
||||||
|
echo ' ..ooo.
|
||||||
|
.888888888.
|
||||||
|
88"P""T"T888 8o'
|
||||||
|
echo " o8o ${red}8.8\"8 88o.\"8o${nc} 8o"
|
||||||
|
echo " 88 . ${red}o88o8 8 88.\"8${nc} 88P\"o"
|
||||||
|
echo " 88 o8 ${red}88 oo.8 888 8${nc} 888 88"
|
||||||
|
echo " 88 88 ${red}88o888\" 88\"${nc} o888 88"
|
||||||
|
echo " 88.\"8o.${red}\"T88P.88\"${nc}. 88888 88"
|
||||||
|
echo " 888.\"888.${red}\"88P\"${nc}.o8 8888 888"
|
||||||
|
echo ' "888o"8888oo8888 o888 o8P"
|
||||||
|
"8888.""888P"P.888".88P
|
||||||
|
"88888ooo 888P".o888
|
||||||
|
""8P"".oooooo8888P
|
||||||
|
.oo888ooo. 8888NICK8P8
|
||||||
|
o88888"888"88o. "8888"".88 .oo888oo..
|
||||||
|
8888" "88 88888. 88".o88888888"888.
|
||||||
|
"8888o.""o 88"88o. o8".888"888"88 "88P
|
||||||
|
T888C.oo. "8."8"8 o8"o888 o88" ".=888"
|
||||||
|
88888888o "8 8 8 .8 .8"88 8"".o888o8P
|
||||||
|
"8888C.o8o 8 8 8" 8 o" ...o"""8888
|
||||||
|
"88888888 " 8 .8 8 88888888888"
|
||||||
|
"8888888o .8o=" o8o..o(8oo88"
|
||||||
|
"888" 88" 888888888""
|
||||||
|
o8P "888"""
|
||||||
|
...oo88'
|
||||||
|
|
||||||
|
# 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}"
|
||||||
|
echo "=|:^) Art: https://www.asciiart.eu/plants/flowers =|:^)"
|
||||||
|
sleep 1
|
||||||
|
|
1
dwm-stat/.gitignore
vendored
Normal file
1
dwm-stat/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
statline
|
8
dwm-stat/Makefile
Normal file
8
dwm-stat/Makefile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
stat:
|
||||||
|
gcc -o statline status.c -O2 -s -lX11
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f statline
|
||||||
|
|
||||||
|
install:
|
||||||
|
ln -s $(shell pwd)/statline /usr/bin/statline
|
124
dwm-stat/status.c
Normal file
124
dwm-stat/status.c
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
// statline by shockrah
|
||||||
|
// Inspired by barM
|
||||||
|
// barM is a great tool but formats information in a really ugly fashion
|
||||||
|
// 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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
|
|
||||||
|
#define BASIC_MSG "/comfy/ o clock | "
|
||||||
|
#define TIME_FORMAT "%I:%M%p - %d %b %Y"
|
||||||
|
|
||||||
|
#define TIME_DELAY 5
|
||||||
|
#define MAXSTR 1024
|
||||||
|
|
||||||
|
#define MEM_BREAD_SIZE 32
|
||||||
|
#define STD_IO
|
||||||
|
|
||||||
|
// `man date` should give you some more info on what the format specs do
|
||||||
|
// This format give the form » 05:13 PM - 20 Jul 2019
|
||||||
|
static char*
|
||||||
|
date_time(void)
|
||||||
|
{
|
||||||
|
static char date[MAXSTR];
|
||||||
|
time_t now = time(0);
|
||||||
|
|
||||||
|
strftime(date, sizeof(date), TIME_FORMAT, localtime(&now));
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
ram_usage(void)
|
||||||
|
{
|
||||||
|
struct sysinfo info;
|
||||||
|
sysinfo(&info);
|
||||||
|
static char buf[MAXSTR];
|
||||||
|
long sum;
|
||||||
|
|
||||||
|
// TODO: fix the Lazily reading through /proc/meminfo
|
||||||
|
FILE* res = popen("cat /proc/meminfo | grep -e ^Cached -e Buffers -e Slab | awk '{print $2}'", "r");
|
||||||
|
if(res) {
|
||||||
|
sum = 0;
|
||||||
|
while(fgets(buf, sizeof(buf)-1, res) != NULL) {
|
||||||
|
sum += atoi(buf);
|
||||||
|
}
|
||||||
|
sum *= 1000; // KB to B
|
||||||
|
}
|
||||||
|
double used = (info.totalram - info.freeram - sum) / 1000000000.;
|
||||||
|
double total = info.totalram / 1000000000.;
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "%.2f G/ %.1f G", used, total);
|
||||||
|
pclose(res);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char*
|
||||||
|
cpu_usage(void)
|
||||||
|
{
|
||||||
|
return "CPU Usage Placeholder";
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
XSetRoot(char* name)
|
||||||
|
{
|
||||||
|
Display *display;
|
||||||
|
|
||||||
|
if (( display = XOpenDisplay(0x0)) == NULL ) {
|
||||||
|
fprintf(stderr, "[barM] cannot open display!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
XStoreName(display, DefaultRootWindow(display), name);
|
||||||
|
XSync(display, 0);
|
||||||
|
|
||||||
|
XCloseDisplay(display);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
// Here you can put the functions you create as they should be executed from here
|
||||||
|
static char* (*func_table[])(void) = {
|
||||||
|
ram_usage,
|
||||||
|
date_time,
|
||||||
|
};
|
||||||
|
|
||||||
|
char stat_output[MAXSTR];
|
||||||
|
// First things that don't need updating like ever
|
||||||
|
int base_len = snprintf(stat_output, sizeof(stat_output), BASIC_MSG);
|
||||||
|
char* base_offset = stat_output + base_len;
|
||||||
|
|
||||||
|
// Make sure we didn't go past the end of our buffer
|
||||||
|
if(base_offset >= sizeof(stat_output)+stat_output) {
|
||||||
|
XSetRoot(stat_output);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
// Now the regularly updated stuff like date/time cpu usage etc.
|
||||||
|
int len;
|
||||||
|
for(;;) {
|
||||||
|
int remainder = sizeof(stat_output) - base_len; // starting position for 'dynamic text'
|
||||||
|
char* tmp_base_ptr = base_offset;
|
||||||
|
for(int i = 0; i < sizeof(func_table)/sizeof(func_table[0]); ++i) {
|
||||||
|
if(tmp_base_ptr > (stat_output+MAXSTR)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int written = snprintf(tmp_base_ptr, remainder, "%s | ", func_table[i]());
|
||||||
|
tmp_base_ptr += written;
|
||||||
|
remainder -= written;
|
||||||
|
}
|
||||||
|
|
||||||
|
XSetRoot(stat_output);
|
||||||
|
sleep(TIME_DELAY);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
43
newbga
Executable file
43
newbga
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Shoutout to mitchweaver on gitgub for the script as a useful base for this one
|
||||||
|
# Link to exact script: https://github.com/mitchweaver/bin/blob/master/mpv/mpvbg
|
||||||
|
# There's lots of good scripts in that repository so check them all out
|
||||||
|
|
||||||
|
pkill -9 xwinwrap
|
||||||
|
cacheFile="${HOME}/.cache/mpvbg.pid"
|
||||||
|
base="/home/shockrah/Pictures/VPapes"
|
||||||
|
|
||||||
|
# Pic two random video papes
|
||||||
|
pape1=`ls "${HOME}/Pictures/VPapes" | shuf | head -n 1`
|
||||||
|
pape2=`ls "${HOME}/Pictures/VPapes" | shuf | head -n 1`
|
||||||
|
while "$pape1" = "$pape2"
|
||||||
|
do
|
||||||
|
pape2=`ls "${HOME}/Pictures/VPapes" | shuf | head -n 1`
|
||||||
|
done
|
||||||
|
|
||||||
|
mpv="mpv --wid WID --no-config --keepaspect=no --loop \
|
||||||
|
--no-border --vd-lavc-fast --x11-bypass-compositor=no \
|
||||||
|
--gapless-audio=yes --vo=x11 --hwdec=auto \
|
||||||
|
--x11-name=mpvbg"
|
||||||
|
|
||||||
|
# store our pid here so we can avoid killing our background later
|
||||||
|
# Example: $ kill $(pgrep mpv | grep -v $(pgrep -P $(cat ${HOME}/.cache/mpvbg.pid)))
|
||||||
|
# --- Here we are killing "all mpvs, except with THIS PID"
|
||||||
|
# --- This lets us kill a video we're watching, without stopping our desktop background!
|
||||||
|
|
||||||
|
|
||||||
|
# First monitor
|
||||||
|
xwinwrap -g 1920x1080 -ni -fdt -sh rectangle -un -b -nf -ov -- $mpv "$base/$pape1" & > /dev/null 2>&1 &
|
||||||
|
echo $! > ${HOME}/.cache/mpvbg.pid
|
||||||
|
|
||||||
|
# Quick check if we even have a second monitor at all
|
||||||
|
c=`xrandr | grep ' connected' | wc -l`
|
||||||
|
if $c = "1"
|
||||||
|
then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
# Second monitor
|
||||||
|
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
|
||||||
|
|
||||||
|
|
17
power
Executable file
17
power
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
off() {
|
||||||
|
systemctl poweroff
|
||||||
|
}
|
||||||
|
reboot() {
|
||||||
|
systemctl reboot
|
||||||
|
}
|
||||||
|
|
||||||
|
opt=`printf 'Off\nReboot' | dmenu -i -p 'Power option'`
|
||||||
|
if [ -z "$opt"]; then exit 0;fi
|
||||||
|
if [ "$opt" = "Off" ]
|
||||||
|
then
|
||||||
|
off
|
||||||
|
else
|
||||||
|
reboot
|
||||||
|
fi
|
9
proj
9
proj
@ -15,12 +15,17 @@ then
|
|||||||
dmenu -i -p 'Pick side'`
|
dmenu -i -p 'Pick side'`
|
||||||
if [ -z "$side" ]; then exit 0; fi
|
if [ -z "$side" ]; then exit 0; fi
|
||||||
|
|
||||||
echo 'xrandr --output $out --auto $side eDP-1'
|
echo "xrandr --output $out --auto $side eDP-1"
|
||||||
xrandr --output $out --auto --$side eDP-1
|
xrandr --output $out --auto --$side DVI-I-1
|
||||||
else
|
else
|
||||||
|
# Get the display we want to remove
|
||||||
out=`xrandr | grep ' connected' | awk '{print $1}' | \
|
out=`xrandr | grep ' connected' | awk '{print $1}' | \
|
||||||
dmenu -i -p 'Device to dettach'`
|
dmenu -i -p 'Device to dettach'`
|
||||||
if [ -z "$out" ]; then exit 0; fi
|
if [ -z "$out" ]; then exit 0; fi
|
||||||
|
|
||||||
|
# Remove that device from xrandr
|
||||||
|
echo "xrandr --output $out --off"
|
||||||
|
xrandr --output $out --off
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
22
readme.md
Normal file
22
readme.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# What is this?
|
||||||
|
|
||||||
|
A collection of shell scripts that I use with dmenu to make my life easier.
|
||||||
|
|
||||||
|
Right now most of them are filled with basisms but thats slowly changing overtime.
|
||||||
|
|
||||||
|
## 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`.
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
|
||||||
|
Scale 0-5
|
||||||
|
|
||||||
|
* 0 = High priority
|
||||||
|
* 5 = Low priority
|
||||||
|
|
||||||
|
|
||||||
|
usbm 0
|
||||||
|
|
||||||
|
* Actually finishing the userland mount script
|
||||||
|
* Remove necessity for root
|
4
sndt
4
sndt
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
# Shut off all sounds coming from alsa
|
# Shut off all sounds coming from alsa (called when locking from lock script"
|
||||||
amixer -q -D pulse sset Master toggle
|
amixer -q -D pulse sset Master toggle
|
||||||
|
9
usbm
9
usbm
@ -1,9 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Mounting script for usb drives for use in dmenu
|
|
||||||
mountable=$(lsblk -lp | grep "part $" | awk '{print $1, $4 }')
|
|
||||||
[ -z "$mountable" ] && exit 0
|
|
||||||
usb=$(echo "$mountable" |\
|
|
||||||
dmenu -i -l 5 -p "Which usb drive should we mount?" |\
|
|
||||||
awk '{print $1}')
|
|
||||||
mkdir -p ~/.mntpts
|
|
||||||
mount $(basename $usb) ~/.mntpts/$(basename $usb)
|
|
29
usm
Normal file → Executable file
29
usm
Normal file → Executable file
@ -1,10 +1,27 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# 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 $' | awk '{print $1, $4}' | grep -v 'sda' | \
|
grep 'disk ' | \
|
||||||
dmenu -i -p 'Drive to mount'`
|
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}'`
|
dev=`echo $choice | awk '{print $1}'`
|
||||||
if [ -z "$dev" ];then exit 0;fi
|
name="`basename $dev`"
|
||||||
# Finally we can mount the thing
|
if [ -z "$dev" ]; then exit; fi
|
||||||
mkdir -p "/mnt/`basename $dev`"
|
if grep -qs "$dev" /proc/mounts;
|
||||||
mount "$dev" "$name"
|
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
|
||||||
|
else
|
||||||
|
# Finally we can mount the thing
|
||||||
|
mkdir -p "~/.mounts/$name"
|
||||||
|
mount "$dev" "~/.mounts/$name"
|
||||||
|
fi
|
||||||
|
5
wed
5
wed
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
choice=$(printf "on\noff" | dmenu -i -p "Wifi $(nmcli r w)")
|
stat=`nmcli r w`
|
||||||
[ -z "$choice" ] && exit 0
|
choice=`printf "on\noff" | dmenu -i -p "Wifi $stat"`
|
||||||
|
if [ -z "$choice" ]; then exit;fi
|
||||||
nmcli r w $choice
|
nmcli r w $choice
|
||||||
|
24
ytdl
24
ytdl
@ -1,8 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
dir=$(find ~/Music/ -maxdepth 1 -type d | dmenu -i -p "Pick a directory")
|
dir=`for d in ~/Music/*;do
|
||||||
url="$(echo '' | dmenu -p 'Enter a url')"
|
if [ -d "$d" ]
|
||||||
[ -z "$url" ] && exit 0
|
then
|
||||||
youtube-dl --extract-audio \
|
basename "$d"
|
||||||
|
fi
|
||||||
|
done | dmenu -i -l 10 -p 'Pick a directory'`
|
||||||
|
echo ~/Music/$dir
|
||||||
|
if [ -z "$dir" ]; then exit; fi
|
||||||
|
|
||||||
|
url=`echo '' | dmenu -p 'Enter a url'`
|
||||||
|
if [ -z "$url" ]; then exit; fi
|
||||||
|
|
||||||
|
# youtube-dl constantly breaks so --verbose is here for your pleasure
|
||||||
|
youtube-dl --extract-audio --verbose \
|
||||||
--audio-format mp3 \
|
--audio-format mp3 \
|
||||||
-o "$dir/%(title)s.%(ext)s" \
|
-o "~/Music/$dir/%(title)s.%(ext)s" \
|
||||||
$url
|
"$url"
|
||||||
|
Loading…
Reference in New Issue
Block a user