refactor: new system basics
This commit is contained in:
43
utils/auto_xrandr.sh
Executable file
43
utils/auto_xrandr.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
## open if opened
|
||||
is_lid_open="$(cat /proc/acpi/button/lid/LID0/state | awk '{print $2}')"
|
||||
|
||||
# Only allow 1 extra monitor
|
||||
aditional_monitor_option=""
|
||||
clean_monitor_option=""
|
||||
|
||||
output_new="$(xrandr | grep "HDMI-A-0 connected")"
|
||||
if [[ ${#output_new} -ne 0 ]]; then
|
||||
aditional_monitor_option="--output HDMI-A-0 --auto --above eDP"
|
||||
else
|
||||
clean_monitor_option+="--output HDMI-A-0 --off "
|
||||
fi
|
||||
|
||||
output_new="$(xrandr | grep "DisplayPort-0 connected")"
|
||||
if [[ ${#output_new} -ne 0 ]]; then
|
||||
aditional_monitor_option="--output DisplayPort-0 --auto --above eDP"
|
||||
else
|
||||
clean_monitor_option+="--output DisplayPort-0 --off "
|
||||
fi
|
||||
|
||||
output_new="$(xrandr | grep "DisplayPort-1 connected")"
|
||||
if [[ ${#output_new} -ne 0 ]]; then
|
||||
aditional_monitor_option="--output DisplayPort-1 --auto --above eDP"
|
||||
else
|
||||
clean_monitor_option+="--output DisplayPort-1 --off "
|
||||
fi
|
||||
|
||||
base_monitor_option="--output eDP --auto --primary"
|
||||
[[ "$is_lid_open" != "open" && ${#aditional_monitor_option} -ne 0 ]] && base_monitor_option="--output eDP --off"
|
||||
|
||||
xrandr $clean_monitor_option $base_monitor_option $aditional_monitor_option
|
||||
|
||||
if [[ ${#aditional_monitor_option} -eq 0 && $is_lid_open != "open" ]]; then
|
||||
betterlockscreen -l -w &
|
||||
systemctl suspend
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bash ~/.config/bspwm/bspwmrc
|
||||
bash ~/.config/polybar/launch.sh
|
||||
18
utils/clipboard_background_manager.sh
Normal file
18
utils/clipboard_background_manager.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
HISTORY_LENGTH=8
|
||||
HISTORY_FILE_PATH=~/.tmp/clipboard_history.txt
|
||||
|
||||
touch $HISTORY_FILE_PATH >/dev/null
|
||||
|
||||
while clipnotify; do
|
||||
new_clip=$(xsel -b -o)
|
||||
is_found=$(grep -Fx "$new_clip" $HISTORY_FILE_PATH)
|
||||
if [ ${#is_found} -eq 0 ]; then
|
||||
echo "$new_clip" >> $HISTORY_FILE_PATH
|
||||
file_size=$(wc -l < $HISTORY_FILE_PATH)
|
||||
if [ $file_size -gt $HISTORY_LENGTH ]; then
|
||||
sed -i '1d' $HISTORY_FILE_PATH
|
||||
fi
|
||||
fi
|
||||
done
|
||||
16
utils/configure_touchpad.sh
Normal file
16
utils/configure_touchpad.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
id=$(xinput list | grep Touchpad | awk '{print $6}' | grep -o '[0-9]\+')
|
||||
tap=$(xinput list-props $id | grep "Tapping Enabled (" | awk '{print $4}' | grep -o '[0-9]\+')
|
||||
speed=$(xinput list-props $id | grep "Accel Speed (" | awk '{print $4}' | grep -o '[0-9]\+')
|
||||
scroll=$(xinput list-props $id | grep "Natural Scrolling Enabled (" | awk '{print $5}' | grep -o '[0-9]\+')
|
||||
|
||||
echo $id $tap $speed
|
||||
|
||||
xinput set-prop $id $tap 1
|
||||
xinput set-prop $id $speed 0.12
|
||||
xinput set-prop $id $scroll 1
|
||||
|
||||
unset id
|
||||
unset prop
|
||||
unset val
|
||||
6
utils/lock
Executable file
6
utils/lock
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
# --off 16 is no necessary right now since the screen is turned off before the lock
|
||||
#betterlockscreen --off 16 -l -w &
|
||||
betterlockscreen -l -w &
|
||||
# systemctl suspend
|
||||
|
||||
78
utils/scratch
Executable file
78
utils/scratch
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
name="$1"
|
||||
filename=/tmp/"$1"
|
||||
|
||||
bspc_write_nodeid() {
|
||||
while true
|
||||
do
|
||||
flag=false
|
||||
for id in $(bspc query -d focused -N -n .floating.sticky.hidden)
|
||||
do
|
||||
bspc query --node $id -T | grep -q $name && { echo $id > $filename; flag=true; break; }
|
||||
done
|
||||
[[ "$flag" == "true" ]] && break
|
||||
sleep 0.1s
|
||||
done
|
||||
}
|
||||
|
||||
hide_all_except_current(){
|
||||
for id in $(bspc query -d focused -N -n .floating.sticky.!hidden)
|
||||
do
|
||||
bspc query --node $id -T | grep -qv $name && bspc node $id --flag hidden=on
|
||||
done
|
||||
}
|
||||
|
||||
toggle_hidden() {
|
||||
[ -e "$filename" ] || exit 1
|
||||
hide_all_except_current
|
||||
id=$(<$filename)
|
||||
bspc node $id --flag hidden -f
|
||||
}
|
||||
|
||||
create_terminal(){
|
||||
st -c "$name" -n "$name" -e $1 &
|
||||
}
|
||||
|
||||
set_sizes() {
|
||||
files_window_id=$(xdotool search --class "files-scratch" | head -n 1)
|
||||
if [ ! -z "$files_window_id" ]; then
|
||||
echo "found $files_window_id"
|
||||
xdo resize -w 1864 -h 982 "$files_window_id"
|
||||
xdo move -x 28 -y 70 "$files_window_id"
|
||||
fi
|
||||
|
||||
# bpytop_window_id=$(xdotool search --class "bpytop-scratch" | head -n 1)
|
||||
# if [ ! -z "$bpytop_window_id" ]; then
|
||||
# echo "found $bpytop_window_id"
|
||||
# xdo resize -w 1100 -h 800 "$bpytop_window_id"
|
||||
# xdo move -x 0 -y 0 "$bpytop_window_id"
|
||||
# fi
|
||||
}
|
||||
|
||||
if ! ps -ef | grep -q "[-]c $name"
|
||||
then
|
||||
bspc rule -a "$name" --one-shot state=floating sticky=on hidden=on
|
||||
case "$name" in
|
||||
"bpytop-scratch")
|
||||
create_terminal bpytop
|
||||
;;
|
||||
"files-scratch")
|
||||
create_terminal nnn
|
||||
;;
|
||||
"terminal-scratch")
|
||||
create_terminal $SHELL
|
||||
;;
|
||||
"bc-scratch")
|
||||
create_terminal bc
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
esac
|
||||
bspc_write_nodeid
|
||||
toggle_hidden
|
||||
else
|
||||
toggle_hidden
|
||||
fi
|
||||
|
||||
set_sizes
|
||||
52
utils/selectors/audio_output.sh
Normal file
52
utils/selectors/audio_output.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
# pactl list sinks | grep -e "Name" -e "Description"
|
||||
# pactl set-default-sink
|
||||
# HiFi__Headphones__sink -> laptop
|
||||
# bluez_sink -> bluetooth
|
||||
# USB_Audio_Device -> usb headset
|
||||
# usb-Synaptics -> usb-c headset
|
||||
# <HDMI1/HDMI2/HDMI3>__sink -> Screen
|
||||
getFormalNameFromSink() {
|
||||
case "$1" in
|
||||
*HiFi__Headphones__sink*)
|
||||
echo "Laptop speakers"
|
||||
;;
|
||||
*bluez*)
|
||||
echo "Bluetooth audio"
|
||||
;;
|
||||
*usb-Synaptics*)
|
||||
echo "USB-c audio"
|
||||
;;
|
||||
*USB*)
|
||||
echo "USB audio"
|
||||
;;
|
||||
*HDMI*)
|
||||
echo "External screen audio"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
declare -A sink_map
|
||||
declare menu_options
|
||||
|
||||
sink_list=$(pactl list sinks | grep -e "Name" | awk -F: '{print $2}' | xargs)
|
||||
|
||||
for sink in $sink_list; do
|
||||
formal_name=$(getFormalNameFromSink $sink)
|
||||
sink_map["$formal_name"]="$sink"
|
||||
if [[ ${#menu_options} -ne 0 ]]; then
|
||||
menu_options="$menu_options|"
|
||||
fi
|
||||
menu_options="$menu_options$formal_name"
|
||||
done
|
||||
|
||||
chosen_option="$(rofi -no-config -no-lazy-grab -sep "|" -dmenu -i -p 'Audio outputs' -width 12 -line-padding 3 -lines 6 <<< "$menu_options")"
|
||||
|
||||
[[ "$chosen_option" == "" ]] && exit 0
|
||||
|
||||
chosen_sink="${sink_map["$chosen_option"]}"
|
||||
|
||||
pactl set-default-sink $chosen_sink
|
||||
|
||||
notify-send -t 3500 "Default Audio output" "$chosen_option"
|
||||
9
utils/selectors/clipboard_history.sh
Normal file
9
utils/selectors/clipboard_history.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
HISTORY_FILE_PATH=~/.tmp/clipboard_history.txt
|
||||
|
||||
clip_options=$(cat $HISTORY_FILE_PATH)
|
||||
|
||||
chosen_option="$(rofi -no-config -no-lazy-grab -sep "\n" -dmenu -i -p 'Audio outputs' -width 12 -line-padding 3 -lines 8 <<< "$clip_options")"
|
||||
|
||||
echo -n $chosen_option | xsel -b
|
||||
10
utils/styles/colors.rasi
Normal file
10
utils/styles/colors.rasi
Normal file
@@ -0,0 +1,10 @@
|
||||
/* colors */
|
||||
* {
|
||||
al: #00000000;
|
||||
bg: #121212DF;
|
||||
bga: #101010CA;
|
||||
fg: #f5f5f5FF;
|
||||
ac: #58809aFF;
|
||||
se: #58809a5A;
|
||||
font: "Terminus 12";
|
||||
}
|
||||
0
utils/styles/themes/audio_output.rasi
Normal file
0
utils/styles/themes/audio_output.rasi
Normal file
Reference in New Issue
Block a user