Created
January 7, 2021 21:43
-
-
Save 0Karakurt0/b6902b11fa0ab40c81c96ce18d64a5bf to your computer and use it in GitHub Desktop.
Дурацкая идея русифицировать баш
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# variables | |
X=${X:=0} | |
Y=${Y:=0} | |
window_x=${window_x:=0} | |
window_y=${window_y:=0} | |
window_width=${window_width:=2} | |
window_height=${window_height:=2} | |
instance=${instance:=$TERM} | |
window_count=$(i3-msg -t get_tree | jq -r '.. | .nodes?[]? | select(.window_type == "normal") | .name' | wc -l) | |
# getting cursor coordinates | |
eval $(xdotool getmouselocation --shell) | |
# getting window coordinates and dimentions | |
eval $( i3-msg -t get_tree | jq -r '..|try select(.focused == true)| "window_x=\(.rect.x)\nwindow_y=\(.rect.y)\nwindow_width=\(.rect.width)\nwindow_height=\(.rect.height)\ninstance=\(.window_properties.instance)"' ) | |
waitloop(){ | |
until [ $window_count -lt $new_window_count ]; | |
do | |
new_window_count=$(i3-msg -t get_tree | jq -r '.. | .nodes?[]? | select(.window_type == "normal") | .name' | wc -l) | |
sleep 0.1 | |
done | |
} | |
slicing(){ | |
change=$(( $1 / 2 - ($2 - $3) )) | |
i3-msg split "$5" && $instance & disown && waitloop | |
if [ "$change" -gt 0 ]; then | |
i3-msg resize grow "$4" "$change" | |
else | |
change=$(( change* - 1 )) | |
i3-msg resize shrink "$4" "$change" | |
fi | |
} | |
if [ "$1" = "hor" ]; then slicing $window_height $Y $window_y height v | |
elif [ "$1" = "ver" ]; then slicing $window_width $X $window_x width h | |
fi | |
# Author: Karakurt | |
# Idea: foggalong ( https://www.reddit.com/r/unixporn/comments/8oj2a2/bspwm_slicing_windows/ ) | |
# TODO | |
# - find a way to not depend on focused window | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/zsh | |
# Магия, не подглядывай! | |
ТЕРМИНАЛ=$TERM | |
alias если="if" тогда="then" илсе="fi" из="case" выбрать="in" готово="done" вывод="echo" оценить="eval" пока="until" делать="do" спать="sleep" иначе="else" иначе_если="elif" | |
# Собственно программа | |
X=0 | |
Y=0 | |
x_окна=0 | |
y_окна=0 | |
ширину_окна=2 | |
высоту_окна=2 | |
приложение=$ТЕРМИНАЛ | |
кол_окон=$(i3-msg -t get_tree | jq -r '.. | .nodes?[]? | select(.window_type == "normal") | .name' | wc -l) | |
оценить $(xdotool getmouselocation --shell) | |
оценить $( i3-msg -t get_tree | jq -r '..|try select(.focused == true)| "x_окна=\(.rect.x)\ny_окна=\(.rect.y)\nширину_окна=\(.rect.width)\nвысоту_окна=\(.rect.height)\nприложение=\(.window_properties.instance)"' ) | |
ждём(){ | |
пока [ $кол_окон -lt $нов_кол_окон ]; | |
делать | |
нов_кол_окон=$(i3-msg -t get_tree | jq -r '.. | .nodes?[]? | select(.window_type == "normal") | .name' | wc -l) | |
спать 0.1 | |
готово | |
} | |
рубим(){ | |
разница=$(( $1 / 2 - ($2 - $3) )) | |
i3-msg split "$5" && $приложение & disown && ждём | |
если [ $разница -gt 0 ]; тогда | |
i3-msg resize grow "$4" "$разница" | |
иначе | |
разница=$(( разница * - 1 )) | |
i3-msg resize shrink "$4" "$разница" | |
илсе | |
} | |
если [ "$1" = "гор" ]; тогда рубим $высоту_окна $Y $y_окна height v | |
иначе_если [ "$1" = "вер" ]; тогда рубим $ширину_окна $X $x_окна width h | |
илсе | |
Немного драматургии:
Переводить остаток английского, или не стоит?)
Ещё как стоит! ;-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Немного драматургии:
Переводить остаток английского, или не стоит?)