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 ++++++++++++++++++++++-------- 4 files changed, 55 insertions(+), 30 deletions(-) delete mode 100755 bin/.bin/bat_check (limited to 'bin') 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 + -- cgit v1.2.3