mirror of
https://github.com/GRFreire/scripts.git
synced 2026-03-06 03:09:41 +00:00
Compare commits
6 Commits
6de5431477
...
0974ea361a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0974ea361a | ||
|
|
57d4a3d4bc | ||
|
|
b266682781 | ||
|
|
1d3212efec | ||
|
|
2ff33939d2 | ||
|
|
3d66555b9b |
@ -4,6 +4,6 @@
|
||||
|
||||
device_id="$(xsetwacom list devices | grep STYLUS | cut -f2 | cut -d' ' -f2)"
|
||||
|
||||
xsetwacom set "$device_id" MapToOutput 1920x1080+0+0
|
||||
xsetwacom set "$device_id" MapToOutput 1920x1200+0+0
|
||||
xsetwacom set "$device_id" Area 0 0 15200 8550
|
||||
|
||||
|
||||
1
bin/display-config
Symbolic link
1
bin/display-config
Symbolic link
@ -0,0 +1 @@
|
||||
../display-config/display-config.sh
|
||||
1
bin/display-restore
Symbolic link
1
bin/display-restore
Symbolic link
@ -0,0 +1 @@
|
||||
../display-restore/display-restore.sh
|
||||
1
bin/latex_hotreload
Symbolic link
1
bin/latex_hotreload
Symbolic link
@ -0,0 +1 @@
|
||||
../latex_hotreload/latex_hotreload.sh
|
||||
1
bin/screen-saver
Symbolic link
1
bin/screen-saver
Symbolic link
@ -0,0 +1 @@
|
||||
../screen-saver/screen-saver.sh
|
||||
@ -6,6 +6,10 @@ time="$(upower -i $DEVICE | grep time | cut -d':' -f2 | tr -s ' ' | cut -c2-)"
|
||||
perc="$(upower -i $DEVICE | grep percentage | awk '{print $2}' | tr -d '%')"
|
||||
stat="$(upower -i $DEVICE | grep state | awk '{print $2}')"
|
||||
|
||||
if [ "$stat" = "charging" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$perc" -le "20" ]; then
|
||||
urgency="normal"
|
||||
if [ "$perc" -le "10" ]; then
|
||||
|
||||
7
display-config/README.md
Normal file
7
display-config/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# display-config
|
||||
|
||||
## About
|
||||
-- about section here --
|
||||
|
||||
## Requirements
|
||||
-- any requirements --
|
||||
128
display-config/display-config.sh
Executable file
128
display-config/display-config.sh
Executable file
@ -0,0 +1,128 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$(command -v rofi)" ]; then
|
||||
CMD='rofi -dmenu -i';
|
||||
elif [ "$(command -v dmenu)" ]; then
|
||||
CMD='dmenu';
|
||||
else
|
||||
echo 'Could not find either dmenu or rofi, exiting'
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# $1 - monitor name
|
||||
#
|
||||
# return "WIDTH1xHEIGTH1\nWIDTH2xHEIGTH2\n..."
|
||||
get_monitor_sizes() {
|
||||
xrandr | awk -v monitor="$1" \
|
||||
'$1 == monitor { display=1; next } /^[A-Z]/ { display=0 } display { print $1 }'
|
||||
}
|
||||
|
||||
# $1 - monitor name
|
||||
#
|
||||
# return xrandr "--mode WIDTHxHEIGTH" or "--preferred"
|
||||
monitor_config() {
|
||||
sizes="$(get_monitor_sizes "$1")"
|
||||
if [ "$1" = "eDP-1" ]; then
|
||||
DISPLAY_CONFIGS="Preferred\n$sizes"
|
||||
else
|
||||
DISPLAY_CONFIGS="$sizes"
|
||||
fi
|
||||
|
||||
CONFIG="$(echo "$DISPLAY_CONFIGS" | $CMD -p "Monitor $1 config" | xargs)"
|
||||
|
||||
case "$CONFIG" in
|
||||
Preferred)
|
||||
echo "--preferred"
|
||||
return
|
||||
;;
|
||||
"")
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
echo "--mode $CONFIG"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# return "eDP-1\nHDMI-1\n..."
|
||||
get_monitors() {
|
||||
xrandr | awk '$2 == "connected" {print $1}'
|
||||
}
|
||||
|
||||
monitors="$(get_monitors)"
|
||||
n_monitors="$(echo "$monitors" | wc -l)"
|
||||
|
||||
if [ "$n_monitors" -eq "1" ]; then
|
||||
config="$(monitor_config "$monitors")" || exit 1
|
||||
# shellcheck disable=SC2086
|
||||
xrandr --output "$monitors" $config
|
||||
elif [ "$n_monitors" -eq "2" ]; then
|
||||
DISPLAY_ARRANGEMENTS="Join\nMirror\nOnly"
|
||||
N_ARRANGEMENTS="$(echo $DISPLAY_ARRANGEMENTS | wc -l)"
|
||||
ARRANGEMENT="$(echo "$DISPLAY_ARRANGEMENTS" | $CMD -l "$N_ARRANGEMENTS" -p "Display arrangement" | xargs)"
|
||||
|
||||
case "$ARRANGEMENT" in
|
||||
Join)
|
||||
args=""
|
||||
|
||||
prev_monitor=""
|
||||
for monitor in $(get_monitors); do
|
||||
position=""
|
||||
if [ "$prev_monitor" != "" ]; then
|
||||
POSITIONS="right-of\nleft-of\nabove\nbelow"
|
||||
N_POSITIONS=4
|
||||
position_flag="$(echo "$POSITIONS" | $CMD -l "$N_POSITIONS" -p "Select position" | xargs)"
|
||||
if [ "$position_flag" = "" ]; then exit 1; fi
|
||||
|
||||
position="--$position_flag $prev_monitor"
|
||||
fi
|
||||
config="$(monitor_config "$monitor")" || exit 1
|
||||
args="$args --output $monitor $config $position"
|
||||
prev_monitor="$monitor"
|
||||
done
|
||||
# shellcheck disable=SC2086
|
||||
xrandr $args
|
||||
;;
|
||||
Mirror)
|
||||
args=""
|
||||
|
||||
prev_monitor=""
|
||||
for monitor in $(get_monitors); do
|
||||
config="$(monitor_config "$monitor")" || exit 1
|
||||
args="$args --output $monitor $config"
|
||||
if [ "$prev_monitor" != "" ]; then
|
||||
args="$args --same-as $prev_monitor"
|
||||
fi
|
||||
prev_monitor="$monitor"
|
||||
done
|
||||
# shellcheck disable=SC2086
|
||||
xrandr $args
|
||||
;;
|
||||
Only)
|
||||
monitors="$(get_monitors)"
|
||||
n_monitors="$(echo "$monitors" | wc -l)"
|
||||
monitor="$(echo "$monitors" | $CMD -l "$n_monitors" -p "Select monitor" | xargs)"
|
||||
if [ "$monitor" = "" ]; then exit 1; fi
|
||||
config="$(monitor_config "$monitor")" || exit 1
|
||||
|
||||
args=""
|
||||
for monitor_i in $monitors; do
|
||||
if [ "$monitor_i" = "$monitor" ]; then
|
||||
args="$args --output $monitor_i $config"
|
||||
else
|
||||
args="$args --output $monitor_i --off"
|
||||
fi
|
||||
done
|
||||
# I do want word splitting for argument config
|
||||
# shellcheck disable=SC2086
|
||||
xrandr $args
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
else
|
||||
arandr
|
||||
fi
|
||||
|
||||
7
display-restore/README.md
Normal file
7
display-restore/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# display-restore
|
||||
|
||||
## About
|
||||
-- about section here --
|
||||
|
||||
## Requirements
|
||||
-- any requirements --
|
||||
23
display-restore/display-restore.sh
Executable file
23
display-restore/display-restore.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
restore() {
|
||||
n_active_displays="$(xrandr | awk '/ connected/ && /[0-9]+x[0-9]+\+[0-9]+\+[0-9]+/ { print $1 }' | wc -l)"
|
||||
|
||||
if [ "$n_active_displays" -ge "1" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
monitor="$(xrandr | awk '$2 == "connected" {print $1; exit}')"
|
||||
|
||||
xrandr --output "$monitor" --preferred
|
||||
}
|
||||
|
||||
if [ "$1" = "loop" ]; then
|
||||
while true
|
||||
do
|
||||
restore
|
||||
sleep 5
|
||||
done
|
||||
else
|
||||
restore
|
||||
fi
|
||||
7
latex_hotreload/README.md
Normal file
7
latex_hotreload/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# latex_hotreload
|
||||
|
||||
## About
|
||||
-- about section here --
|
||||
|
||||
## Requirements
|
||||
-- any requirements --
|
||||
51
latex_hotreload/latex_hotreload.sh
Executable file
51
latex_hotreload/latex_hotreload.sh
Executable file
@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
entry="$1"
|
||||
files_to_watch=$()
|
||||
|
||||
if [ -z "$entry" ]; then
|
||||
echo "Error: no entry provided. See --help for usage"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$entry" == "--help" ]; then
|
||||
echo "Usage: latex_hotreload [OPTIONS] entry_tex_file"
|
||||
echo ""
|
||||
echo " OPTIONS:"
|
||||
echo " --help: show this help"
|
||||
echo ""
|
||||
echo " STDIN:"
|
||||
echo " The stdin should contain the files that should be watched for recompilation"
|
||||
echo " Defaults to ./*.tex"
|
||||
echo ""
|
||||
echo " ARGUMENTS:"
|
||||
echo " entry_tex_file: the entry latex file for compilation"
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
output="$(echo "$entry" | sed 's/\.tex$/.pdf/')"
|
||||
|
||||
if test ! -t 0; then
|
||||
while IFS= read -r line
|
||||
do
|
||||
files_to_watch+=("$line")
|
||||
done
|
||||
|
||||
files=$(printf "%s" "${files_to_watch[*]}")
|
||||
files="$(echo $files | sed 's/ /\n/')"
|
||||
else
|
||||
files="$(find . -type f | grep "\.tex")"
|
||||
fi
|
||||
|
||||
echo $files | sed 's/ /\n/g' | entr -s "pdflatex -shell-escape $entry" &
|
||||
entr_pid=$!
|
||||
|
||||
while [ ! -f "$output" ]
|
||||
do
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
zathura "$output"
|
||||
|
||||
kill -s 2 "$entr_pid"
|
||||
@ -3,6 +3,7 @@
|
||||
id="$(xinput list | grep Touchpad | cut -f 2 | sed 's/id=//')"
|
||||
|
||||
xinput disable "$id"
|
||||
sleep 1
|
||||
xinput enable "$id"
|
||||
|
||||
# $1 prop name
|
||||
@ -22,3 +23,7 @@ xinput set-prop "$id" "$prop" 1, 1, 1, 2, 1, 3
|
||||
# Enable Horizontal and Vertical Two-Finger scrolling
|
||||
prop="$(get_prop 'Synaptics Two-Finger Scrolling')"
|
||||
xinput set-prop "$id" "$prop" 1, 1
|
||||
|
||||
if [ "$1" = "--notify" ]; then
|
||||
notify-send -u "low" --icon="input-touchpad" "Restarting touchpad"
|
||||
fi
|
||||
|
||||
7
screen-saver/README.md
Normal file
7
screen-saver/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# screen-saver
|
||||
|
||||
## About
|
||||
-- about section here --
|
||||
|
||||
## Requirements
|
||||
-- any requirements --
|
||||
4
screen-saver/screen-saver.sh
Executable file
4
screen-saver/screen-saver.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
id="$(xprop | grep WM_CLIENT_LEADER | cut -d' ' -f5)"
|
||||
xdg-screensaver suspend "$id"
|
||||
Loading…
Reference in New Issue
Block a user