From 72ccd83ccc66d942b855fe8379bc3f0d24384b76 Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Sun, 23 May 2021 00:48:51 +0530 Subject: improved scripts --- bin/.bin/bat | 34 ++++++++++++++++++++++++++++------ bin/.bin/bat_check | 14 -------------- bin/.bin/disp | 7 +++++-- bin/.bin/record | 30 ++++++++++++++++++++++-------- bspwm/.config/bspwm/bspwmrc | 10 +++------- polybar/.config/polybar/launch | 12 ++++++++++++ polybar/.config/polybar/launch.sh | 12 ------------ x/.xinitrc | 4 ++++ 8 files changed, 74 insertions(+), 49 deletions(-) delete mode 100755 bin/.bin/bat_check create mode 100755 polybar/.config/polybar/launch delete mode 100755 polybar/.config/polybar/launch.sh diff --git a/bin/.bin/bat b/bin/.bin/bat index 473c7e2..38f4272 100755 --- a/bin/.bin/bat +++ b/bin/.bin/bat @@ -1,12 +1,34 @@ -#!/bin/bash -while true -do - battery_level=$(cat /sys/class/power_supply/BAT0/capacity) +#!/bin/sh + +pane() { + battery_level=$(cat /sys/class/power_supply/BAT*/capacity) state=$(cat /sys/class/power_supply/BAT0/status) if [ $state == "Charging" ]; then echo -e +$battery_level% else echo -e $battery_level% fi - sleep 3 -done +} + +notifs() { + while true + do + battery_level=$(cat /sys/class/power_supply/BAT*/capacity) + state=$(cat /sys/class/power_supply/BAT*/status) + if [ $battery_level -ge 90 ] && [ $state == "Charging" ]; then + notify-send 'Pull the plug!' $battery_level% + elif [ $battery_level -le 30 -a $battery_level -ge 20 ] && [ $state == "Discharging" ]; then + notify-send 'Plug me!' $battery_level% + elif [ $battery_level -le 20 ] && [ $state == "Discharging" ]; then + notify-send -u critical 'Plug me NOW!' $battery_level% + fi + sleep 300 + done +} + +case "$1" in + n) + notifs;; + *) + pane;; +esac diff --git a/bin/.bin/bat_check b/bin/.bin/bat_check deleted file mode 100755 index 547b976..0000000 --- a/bin/.bin/bat_check +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -while true -do - battery_level=$(cat /sys/class/power_supply/BAT0/capacity) - state=$(cat /sys/class/power_supply/BAT0/status) - if [ $battery_level -ge 90 ] && [ $state == "Charging" ]; then - notify-send 'Pull the plug!' $battery_level% - elif [ $battery_level -le 30 -a $battery_level -ge 20 ] && [ $state == "Discharging" ]; then - notify-send 'Plug me!' $battery_level% - elif [ $battery_level -le 20 ] && [ $state == "Discharging" ]; then - notify-send -u critical 'Plug me NOW!' $battery_level% - fi - sleep 300 # 300 seconds or 5 minutes -done diff --git a/bin/.bin/disp b/bin/.bin/disp index 89045b2..43d6987 100755 --- a/bin/.bin/disp +++ b/bin/.bin/disp @@ -1,7 +1,10 @@ #!/bin/sh + status=$(cat /sys/class/drm/card0/*HDMI*/status) if [ $status == "connected" ]; then - xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x1080 --rotate normal --output HDMI-1 --mode 1366x768 --pos 0x0 --scale 1.4x1.4 --rotate normal --output DisplayPort-0 --off + xrandr --output eDP-1 --mode 1920x1080 --pos 0x1076 --rotate normal --output HDMI-1 --primary --mode 1366x768 --scale 1.4x1.4 --pos 0x0 --rotate normal --output DP-1 --off + bspc wm -r else - xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-1 --off + xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-1 --off --output DisplayPort-0 --off + bspc wm -r fi diff --git a/bin/.bin/record b/bin/.bin/record index 09ba7d1..86d9b1a 100755 --- a/bin/.bin/record +++ b/bin/.bin/record @@ -1,10 +1,24 @@ #!/bin/bash -ffmpeg -f x11grab \ --s 1920x1080 \ --an -i :0.0 \ --c:v libvpx \ --b:v 5M \ --crf 10 \ --quality realtime \ --y ~/record.mkv +usage() { + echo " +screen recording using ffmpeg +usage: ${0##*/} [ -w/a ] + +option: + -w without audio + -a with audio +" + exit 1 +} + +case $1 in + -w) + ffmpeg -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0 ~/screens/vids/record_$(date +%d-%b-%y-%I:%M%p).mkv + ;; + -a) + ffmpeg -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0 -f pulse -ac 2 -i default ~/screens/vids/record_$(date +%d-%b-%y-%I:%M%p).mkv + ;; + *) usage +esac + diff --git a/bspwm/.config/bspwm/bspwmrc b/bspwm/.config/bspwm/bspwmrc index cfc46bd..7c0df1b 100755 --- a/bspwm/.config/bspwm/bspwmrc +++ b/bspwm/.config/bspwm/bspwmrc @@ -20,16 +20,12 @@ bspc rule -a Steam desktop='^6' bspc rule -a "VirtualBox Manager" desktop='^6' # autostart -xrdb -merge ~/.Xresources & -xsetroot -cursor_name left_ptr & sxhkd & xss-lock -- slock & -xset b off & -xset s 300 & -~/.fehbg & urxvtd & -~/.bin/bat_check & picom --experimental-backends & dunst & -~/.config/polybar/launch.sh & /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 & +~/.fehbg & +~/.config/polybar/launch & +~/.bin/bat n & diff --git a/polybar/.config/polybar/launch b/polybar/.config/polybar/launch new file mode 100755 index 0000000..c39a374 --- /dev/null +++ b/polybar/.config/polybar/launch @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Terminate already running bar instances +killall -q polybar + +# Wait until the processes have been shut down +while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done + +# Launch bar1 and bar2 +polybar top & + +echo "Bars launched..." diff --git a/polybar/.config/polybar/launch.sh b/polybar/.config/polybar/launch.sh deleted file mode 100755 index c39a374..0000000 --- a/polybar/.config/polybar/launch.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -# Terminate already running bar instances -killall -q polybar - -# Wait until the processes have been shut down -while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done - -# Launch bar1 and bar2 -polybar top & - -echo "Bars launched..." diff --git a/x/.xinitrc b/x/.xinitrc index 6455e33..f79fafb 100755 --- a/x/.xinitrc +++ b/x/.xinitrc @@ -2,4 +2,8 @@ setxkbmap -layout us -option caps:ctrl_modifier & xcape -e 'Caps_Lock=Escape' & xinput --disable "ETPS/2 Elantech Touchpad" +xrdb -merge ~/.Xresources & +xsetroot -cursor_name left_ptr & +xset b off & +xset s 300 & exec dbus-run-session bspwm -- cgit v1.2.3