code changes

This commit is contained in:
rootniformaticaservice 2023-03-09 01:41:12 -03:00
parent fcb45d0aac
commit 26efa5d809
5 changed files with 117 additions and 69 deletions

View file

@ -21,44 +21,59 @@ rwm_layout.sh [ -m, -t, -w ]
-w) widespread"
}
# all windows at full screen
monocule() {
for wid in $(lsw); do
wtp 0 0 $SW $SH $wid
done
}
# tiling. Master and stack
tiling() {
wunfocus=$((CMW - 1)) # count unfocused windows
mp=$(atomx WM_MP $RID) # tiling master area percentage
master=$((SW * mp / 100)) # tilling master area
wmaster=$((master - 2*BW)) # master width
xstack=$master # stack X coordinate
ystack=0 # initial stack Y cooordinate
wstack=$((SW - master)) # stack width
hstack=$(((SH - (wunfocus - 1) * 2*BW) / wunfocus)) # stack heigth
wtp 0 0 $wmaster $SH $FW # put focused window as master
for wid in $(lsw | grep -v $FW); do # unfocused windows in stack
wtp $xstack $ystack $wstack $hstack $wid
ystack=$((ystack + hstack + 2*BW)) # incremental stack Y corrdinate
done
}
# widespread
widespread() {
wp=$(atomx WM_WP $RID) # window percentage from atom
ww=$((SW * wp / 100)) # windows width
wh=$((SH * wp / 100)) # windows height
x=$(((RW - ww) / (CMW*2))) # initial X coordinate
y=$(((RH - wh) / (CMW*2))) # initial Y coordinate
xmax=$(((RW - ww) / CMW)) # function X value
ymax=$(((RH - wh) / CMW)) # function Y value
for wid in $(lsw); do # windows in cascade
wtp $x $y $ww $wh $wid
x=$((x + xmax)) # incremental X value
y=$((y + ymax)) # incremental Y value
done
}
if [ -n "$FW" ]; then # if there is a focused window
case $FLAG in
-m) # all windows at full screen
for wid in $(lsw); do
wtp 0 0 $SW $SH $wid
done
-m)
monocule
;;
-t) # tiling. Master and stack
wunfocus=$((CMW - 1)) # count unfocused windows
mp=$(atomx WM_MP $RID) # tiling master area percentage
master=$((SW * mp / 100)) # tilling master area
wmaster=$((master - 2*BW)) # master width
xstack=$master # stack X coordinate
ystack=0 # initial stack Y cooordinate
wstack=$((SW - master)) # stack width
hstack=$(((SH - (wunfocus - 1) * 2*BW) / wunfocus)) # stack heigth
wtp 0 0 $wmaster $SH $FW # put focused window as master
for wid in $(lsw | grep -v $FW); do # unfocused windows in stack
wtp $xstack $ystack $wstack $hstack $wid
ystack=$((ystack + hstack + 2*BW)) # incremental stack Y corrdinate
done
-t)
tiling
;;
-w) # widespread
wp=$(atomx WM_WP $RID)
ww=$((SW * wp / 100)) # windows width
wh=$((SH * wp / 100)) # windows height
x=$(((RW - ww) / (CMW*2))) # initial X coordinate
y=$(((RH - wh) / (CMW*2))) # initial Y coordinate
xmax=$(((RW - ww) / CMW)) # function X value
ymax=$(((RH - wh) / CMW)) # function Y value
for wid in $(lsw); do # windows in cascade
wtp $x $y $ww $wh $wid
x=$((x + xmax)) # incremental X value
y=$((y + ymax)) # incremental Y value
done
-w)
widespread
;;
*)
usage

View file

@ -19,26 +19,35 @@ nowm_ignore.sh [ -i, -u ]
-u) open menu and choose the window/s to unignore"
}
case $FLAG in
-i) # ignore
if [ ! "$(wattr o $FW && echo 1)" ]; then # if override is not set
wtp 0 0 $SW $SH $FW
ignw -s $FW # ignore focused window
chwb -c 000000 $FW # change border color to ignore
# send windows to background
ignore() {
if [ ! "$(wattr o $FW && echo 1)" ]; then # if override is not set
wtp 0 0 $SW $SH $FW
ignw -s $FW # ignore focused window
chwb -c 000000 $FW # change border color to ignore
else
ignw -r $FW # unignore focused window
chwb -c $FG $FW # change border color to active
else
ignw -r $FW # unignore focused window
chwb -c $FG $FW # change border color to active
fi
}
fi
;;
-u) # unignore
if [ -n "$(lsw -o)" ]; then
# restore windows from background
unignore() {
if [ -n "$(lsw -o)" ]; then
otarget=$(for wid in $(lsw -o); do # override target
printf '%s\n' "$wid | $(atomx WM_CLASS $wid) | $(wname $wid)"
done | cut -c 1-100 | $XMENU | cut -d ' ' -f 1)
ignw -r $otarget # unignore otarget
fi
fi
}
case $FLAG in
-i)
ignore
;;
-u)
unignore
;;
*)
usage

View file

@ -4,7 +4,7 @@
. $HOME/.config/rootwm/rwm_var
NAMES=$(cat $HOME/.config/rootwm/names) # disponible names
NAMES="$HOME/.config/rootwm/names" # disponible names
FLAG=$1 # input
FW=$(pfw) # focused window id
AMW=$(lsw) # all maped windows
@ -19,23 +19,30 @@ rwm_groups.sh [ -a, -r, -t ]
-t) togle"
}
case $FLAG in
-a) # create atom in focused window
atomx WM_GROUP=$($XMENU < $NAMES) $FW
;;
-A) # create atom in all maped windows
atomx WM_GROUP=$($XMENU < $NAMES) $AMW
;;
-d) # delete atom from focused window
atomx -d WM_GROUP $FW
;;
-D) # delete atom from all maped windows
atomx -d WM_GROUP $AMW
;;
-t) # togle groups
groups=$(atomx WM_GROUP $(lsw -a) | sort -u) # groups
if [ -n "$groups" ]; then # check if any grpup exist
gtarget=$(printf "$groups" | $XMENU) # group target
# create atom in focused window
add_focused() {
atomx WM_GROUP=$($XMENU < $NAMES) $FW
}
# create atom in all maped windows
add_all() {
atomx WM_GROUP=$($XMENU < $NAMES) $AMW
}
# delete atom from focused window
del_focused() {
atomx -d WM_GROUP $FW
}
del_all() {
atomx -d WM_GROUP $AMW
}
# togle groups
togle() {
groups=$(atomx WM_GROUP $(lsw -a) | sort -u) # groups
if [ -n "$groups" ]; then # check if any grpup exist
gtarget=$(printf "$groups" | $XMENU) # select group target
utarget=$(for wid in $(lsw -u); do # unmaped targets
printf '%s\n' "$wid $(atomx WM_GROUP $wid)" | grep $gtarget
done)
@ -45,7 +52,25 @@ case $FLAG in
fi
done)
mapw -m $utarget & mapw -u $mtarget # map utargets and unmap mtargets
fi
fi
}
case $FLAG in
-a)
add_focused
;;
-A)
add_all
;;
-d)
del_focused
;;
-D)
dell_all
;;
-t)
togle
;;
*)
usage # self-explained

View file

@ -9,5 +9,4 @@ TARGET=$(\
printf '%s\n' "$wid | $(atomx WM_CLASS $wid) | $(wname $wid)"
done | cut -c 1-100 | $XMENU | cut -d '|' -f 1)
sleep .1; # resolve conflicts with nowm_focuswatcher.sh using fzfmenu.sh
rwm_mainrole.sh "$TARGET" # focus target

View file

@ -8,7 +8,7 @@ TARGET=$(pfw) # focused window
NAMES="$HOME/.config/rootwm/names"
if [ "$(atomx WM_CLASS $TARGET)" = "$TERMINAL" ]; then # if any terminal is focused
atomx WM_NAME="_>$($XMENU < $NAMES)" $TARGET # change atom name
atomx WM_NAME="$($XMENU < $NAMES)" $TARGET # change atom name
fi