init
This commit is contained in:
11
scripts/bar_toggle
Executable file
11
scripts/bar_toggle
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
bar_config=$(swaymsg -t get_bar_config "bar-0")
|
||||
|
||||
mode=$(echo "$bar_config" | jq -r '.mode')
|
||||
|
||||
if [ "$mode" == "dock" ]; then
|
||||
swaymsg "bar mode invisible"
|
||||
elif [ "$mode" == "invisible" ]; then
|
||||
swaymsg "bar mode dock"
|
||||
fi
|
19
scripts/brightness
Executable file
19
scripts/brightness
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
NOTIFICATION_ID=9999
|
||||
CURRENT_BRIGHTNESS=$(brightnessctl g)
|
||||
MAX_BRIGHTNESS=$(brightnessctl m)
|
||||
CURRENT_BRIGHTNESS_PERCENT=$((CURRENT_BRIGHTNESS * 100 / MAX_BRIGHTNESS))
|
||||
|
||||
if [ "$1" == "+" ]; then
|
||||
brightnessctl set +1%
|
||||
elif [ "$1" == "-" ]; then
|
||||
brightnessctl set 10%-
|
||||
else
|
||||
notify-send -u normal -r $NOTIFICATION_ID "Ошибка" "Неверный параметр. Используйте '+' или '-'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
UPDATED_BRIGHTNESS=$(brightnessctl g)
|
||||
UPDATED_BRIGHTNESS_PERCENT=$((UPDATED_BRIGHTNESS * 100 / MAX_BRIGHTNESS))
|
||||
notify-send -u normal -i display-brightness-high -r $NOTIFICATION_ID "Уровень яркости" "${UPDATED_BRIGHTNESS_PERCENT}%" -t 400
|
12
scripts/touchpad_toggle
Executable file
12
scripts/touchpad_toggle
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
touchpad_config=$(swaymsg -t get_inputs | jq -c '.[] | select(.type == "touchpad")')
|
||||
dwt_status=$(echo "$touchpad_config" | jq -r '.libinput.dwt')
|
||||
|
||||
if [ "$dwt_status" == "enabled" ]; then
|
||||
swaymsg input type:touchpad dwt disabled
|
||||
swaymsg input type:touchpad events disabled
|
||||
else
|
||||
swaymsg input type:touchpad dwt enabled
|
||||
swaymsg input type:touchpad events enabled
|
||||
fi
|
22
scripts/volume
Executable file
22
scripts/volume
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
MAX_VOLUME=200
|
||||
NOTIFICATION_ID=9999
|
||||
CURRENT_VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -oP '\d+%' | head -1 | tr -d '%')
|
||||
|
||||
if [ "$1" == "+" ]; then
|
||||
if [ "$CURRENT_VOLUME" -lt "$MAX_VOLUME" ]; then
|
||||
pactl set-sink-volume @DEFAULT_SINK@ +10%
|
||||
else
|
||||
notify-send -u normal -r $NOTIFICATION_ID "Невозможно увеличить звук" "Достигнут лимит в $MAX_VOLUME%" -t 400
|
||||
exit 0
|
||||
fi
|
||||
elif [ "$1" == "-" ]; then
|
||||
pactl set-sink-volume @DEFAULT_SINK@ -10%
|
||||
else
|
||||
notify-send -u normal -r $NOTIFICATION_ID "Error" "Invalid parameter. Use '+' or '-'." -t 400
|
||||
exit 1
|
||||
fi
|
||||
|
||||
UPDATED_VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -oP '\d+%' | head -1 | tr -d '%')
|
||||
notify-send -u normal -i audio-volume-high -r $NOTIFICATION_ID "Уровень звука" "${UPDATED_VOLUME}%" -t 400
|
101
scripts/workspace-manager
Executable file
101
scripts/workspace-manager
Executable file
@ -0,0 +1,101 @@
|
||||
#!/bin/dash
|
||||
|
||||
key_input=$1
|
||||
flag=$2
|
||||
|
||||
#
|
||||
# Calc workspace swich
|
||||
#
|
||||
last_workspace=$(cat /tmp/last_workspace 2>/dev/null)
|
||||
f_key_number=$(cat /tmp/f_key_number 2>/dev/null || echo 0)
|
||||
digit_key_number=$(cat /tmp/digit_key_number 2>/dev/null || echo 0)
|
||||
case $key_input in
|
||||
F*) f_key_number=${key_input#F} ;;
|
||||
0) digit_key_number=10;;
|
||||
[1-9]) digit_key_number=$key_input ;;
|
||||
*) echo "Invalid key input"; exit 1 ;;
|
||||
esac
|
||||
workspace_number=$((f_key_number * 10 + digit_key_number))
|
||||
if [ "$workspace_number" -eq "$last_workspace" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#
|
||||
# Hooks
|
||||
#
|
||||
case $workspace_number in
|
||||
30) workspace_number=48 ;;
|
||||
esac
|
||||
|
||||
|
||||
#
|
||||
# swich
|
||||
#
|
||||
if [ "$flag" = "move" ]; then
|
||||
swaymsg move container to workspace number $workspace_number
|
||||
exit 0
|
||||
else
|
||||
swaymsg workspace $workspace_number
|
||||
fi
|
||||
echo "$workspace_number" > /tmp/last_workspace
|
||||
echo "$f_key_number" > /tmp/f_key_number
|
||||
echo "$digit_key_number" > /tmp/digit_key_number
|
||||
|
||||
#
|
||||
# Post swich | Game workspace - disable touchpad
|
||||
#
|
||||
case $workspace_number in
|
||||
51)
|
||||
swaymsg input type:touchpad events disabled
|
||||
;;
|
||||
48)
|
||||
swaymsg input type:touchpad events enabled
|
||||
swaymsg input type:touchpad dwt disabled
|
||||
;;
|
||||
*)
|
||||
swaymsg input type:touchpad events enabled
|
||||
swaymsg input type:touchpad dwt enabled
|
||||
;;
|
||||
esac
|
||||
|
||||
case $workspace_number in
|
||||
*)
|
||||
swaymsg input type:keyboard xkb_switch_layout 0
|
||||
;;
|
||||
esac
|
||||
|
||||
#
|
||||
# Freeze manager
|
||||
#
|
||||
workspaces_data=$(swaymsg -t get_tree | jq --arg ws1 "$workspace_number" --arg ws2 "$last_workspace" '
|
||||
.nodes[]
|
||||
| select(.type == "output")
|
||||
| .nodes[]
|
||||
| select(.type == "workspace" and (.name == $ws1 or .name == $ws2))
|
||||
| {
|
||||
workspace: .name,
|
||||
pids: [(.nodes[]?, .floating_nodes[]?) | select(has("pid")) | .pid]
|
||||
}
|
||||
')
|
||||
pids_unfreeze=$(echo "$workspaces_data" | jq --arg ws "$workspace_number" '
|
||||
select(.workspace == $ws) | .pids[]
|
||||
' | tr '\n' ',')
|
||||
|
||||
if [ -n "$pids_unfreeze" ]; then
|
||||
pkill -SIGCONT -g "${pids_unfreeze%,}"
|
||||
fi
|
||||
|
||||
case $last_workspace in
|
||||
12) exit 0;;
|
||||
13) exit 0;;
|
||||
14) exit 0;;
|
||||
*) exit 0;;
|
||||
esac
|
||||
|
||||
pids_freeze=$(echo "$workspaces_data" | jq --arg ws "$last_workspace" '
|
||||
select(.workspace == $ws) | .pids[]
|
||||
' | tr '\n' ',')
|
||||
|
||||
if [ -n "$pids_freeze" ]; then
|
||||
pkill -SIGSTOP -g "${pids_freeze%,}"
|
||||
fi
|
Reference in New Issue
Block a user