Mayor changes.

This commit is contained in:
#root_informatica 2024-02-22 00:31:42 -03:00
parent 2d4cf4924a
commit 3b30d2b2a8
20 changed files with 266 additions and 426 deletions

View File

@ -2,7 +2,7 @@
## switch between windows ##
. /tmp/wms_var
. $HOME/.config/wms/wms_var
# all maped widnows.
AMW=$(lsw)
@ -18,6 +18,5 @@ if [ -n "$AMW" ]; then
done | cut -c 1-100 | $XMENU | cut -d '|' -f 1)
sleep $DELAY &&
wms_mainrole.sh "$TARGET" # focus target
wms_focuser.sh "$TARGET" # focus target
fi

133
opt/wms_layout.sh Executable file
View File

@ -0,0 +1,133 @@
#!/bin/sh
## some layouts to order the windows ##
. $HOME/.config/wms/wms_var
FLAG=$1
# root window id.
RID=$(lsw -r)
# focused window.
FW=$(pfw)
# count maped windows.
CMW=$(lsw | wc -l)
# root width.
RW=$(wattr w $RID)
# root height.
RH=$(wattr h $RID)
# usable screen width.
SW=$((RW - 2 * BW))
# usable screen height.
SH=$((RH - 2 * BW))
# master area percentage.
MP=60
# gaps.
GAP=6
usage() {
cat<<EOF
usage:
wms_usher.sh [ -m, -t, -w ]
-m) monucule
-t) tiled
-w) widespread
EOF
}
# all windows at full screen
monocule() {
for wid in $(lsw); do
wtp 0 0 $SW $SH $wid
done
}
# tiling. Master and stack
tiling() {
# screen widht width gaps added.
sw=$((RW - 2 * GAP - 2 * BW))
# master screen height.
msh=$((RH - 2 * GAP - 2 * BW))
# stack screen height (( - BW))?
ssh=$((RH - GAP))
# stack windows count.
swcount=$((CMW - 1))
# master area width.
mwidth=$((sw * MP / 100 - 2 * BW))
# master area height.
mheight=$msh
# master X coordinate.
mx=$GAP
# master Y coordinate.
my=$GAP
# stack width.
swidth=$((sw - mwidth - GAP - 2 * BW))
# stack height.
# if swcount in 0 or not.
[ "$swcount" = "0" ] && sheight=ssh \
|| sheight=$((ssh / swcount - GAP - 2 * BW))
# stack x coordinate.
sx=$((mwidth + 2 * GAP + 2 * BW))
# stack y coordinate.
sy=$GAP
if [ "$swcount" = "0" ]; then
wtp $mx $my $sw $msh $FW
else
# put focused window as master
wtp $mx $my $mwidth $mheight $FW
# put the rest of the windows in stack
for wid in $(lsw | grep -v $FW); do
wtp $sx $sy $swidth $sheight $wid
# incremental stack Y coordinate.
sy=$((sy + sheight + GAP + 2 * BW))
done
fi
}
# widespread
widespread() {
# windows width.
ww=$((SW * WP / 100))
# windows height.
wh=$((SH * WP / 100))
# initial X coordinate.
x=$(((RW - ww) / (CMW * 2)))
# initial Y coordinate.
y=$(((RH - wh) / (CMW * 2)))
# function X value.
xmax=$(((RW - ww) / CMW))
# function Y value.
ymax=$(((RH - wh) / CMW))
# put windows in cascade
for wid in $(lsw); do
wtp $x $y $ww $wh $wid
# incremental X value.
x=$((x + xmax))
# incremental Y value.
y=$((y + ymax))
done
}
# if there is a focused window.
if [ -n "$FW" ]; then
case $FLAG in
-m)
monocule
;;
-t)
tiling
;;
-w)
widespread
;;
*)
usage
;;
esac
fi

View File

@ -31,11 +31,11 @@ if [ -f "$TMPIMG" ]; then
# overwrite the values in ~/.config/wms/wms_var
sed -i "s/^.*\bAC=\b.*$/AC=$ac/" $WMSVAR # new acive color
sed -i "s/^.*\bIC=\b.*$/IC=$ic/" $WMSVAR # new inactive color
sed -i "s/^.*\bBC=\b.*$/BC=$bc/" $WMSVAR # new background color
# sed -i "s/^.*\bBC=\b.*$/BC=$bc/" $WMSVAR # new background color
# overwrite the xterm, emacs and nsxiv values in ~/.Xresources
sed -i "s/\(XTerm\*background:\).*/\XTerm\*background: \#$bc/" $XVAR
sed -i "s/\(Nsxiv\*window.background:\).*/\Nsxiv\*window.background: \#$bc/" $XVAR
# sed -i "s/\(XTerm\*background:\).*/\XTerm\*background: \#$bc/" $XVAR
# sed -i "s/\(Nsxiv\*window.background:\).*/\Nsxiv\*window.background: \#$bc/" $XVAR
# apply the change
wms_value.sh -d

View File

@ -1,15 +0,0 @@
#!/bin/sh
## check if there is an open Emacs window ##
## dependencies: wname, lsw.
. /tmp/wms_var
# search for editor window open.
TARGET=$(for wid in $(lsw -a); do
printf '%s\n' "$wid $(atomx WM_CLASS $wid)"
done | grep $XENAME | cut -d ' ' -f1)
# if editor window is open, focus it; else, start editor.
[ $TARGET ] && wms_mainrole.sh $TARGET \
|| $XECMD

View File

@ -2,7 +2,7 @@
## give windows the stardom ##
. /tmp/wms_var
. $HOME/.config/wms/wms_var
FLAG=$1
# focused window.
@ -64,6 +64,6 @@ esac
wtf $wid
# set colors on the unfocused windows.
chwb -s $BW -c $IC $(lsw | grep -v $(pfw))
chwb -s $BW -c $IC $(lsw | grep -v $wid)
# set colors on the focused widnow.
chwb -s $BW -c $AC $(pfw)
chwb -s $BW -c $AC $wid

View File

@ -1,11 +0,0 @@
#!/bin/sh
. /tmp/wms_var
$TERMINAL -name 'wms_launcher' \
-g $GEOMETRY \
-e bash -c 'cmd=$(compgen -c | sort -u | grep -v fzy | fzy); \
setsid -f $cmd'
# -e bash -c

View File

@ -1,11 +0,0 @@
#!/bin/sh
. /tmp/wms_var
$TERMINAL -name "wms_menu" \
-g $GEOMETRY \
-e "fzy < /proc/$$/fd/0 > /proc/$$/fd/1"
# fzf line:

View File

@ -1,146 +0,0 @@
#!/bin/sh
## move and resize windows ##
. /tmp/wms_var
FLAG=$1
# focused window id.
FW=$(pfw)
# root window id.
RID=$(lsw -r)
# root window width.
RW=$(wattr w $RID)
# root window height.
RH=$(wattr h $RID)
# screen utilizable width.
SW=$((RW - 2 * BW - 2 * GAP))
# screen utilizable height.
SH=$((RH - 2 * BW - 2 * GAP))
usage() {
cat<<EOF
usage:
wms_moveresize.sh [ -n, -s, -e, -o, -r, -l, -d, -u, -w, -W, -h, -H ]
-f) fullsize
-n) half north
-s) half south
-e) half est
-o) half west
-r) move right
-l) move left
-d) move down
-u) move up
-w) resize width -
-W) resize width +
-h) resize height -
-H) resize height +
EOF
}
# half north value
north() {
x=$GAP
y=$GAP
w=$SW
h=$((SH / 2 - GAP - BW))
}
# half south value
south() {
x=$GAP
y=$((SH / 2 + GAP + BW))
w=$SW
h=$((SH / 2))
}
# half est value
est() {
x=$((SW / 2 + GAP + BW))
y=$GAP
w=$((SW / 2))
h=$SH
}
# half west value
west() {
x=$GAP
y=$GAP
w=$((SW / 2 - BW - GAP))
h=$SH
}
# fulsize function
fullsize() {
# original size and position.
osp=$(atomx WM_FS $FW)
# fullsize width.
fs_width=$((RW - BW * 2))
# fullsize height.
fs_height=$((RH - BW * 2))
x=0
y=0
# if atom exist and it is in fullsize
if [ -n "$osp" ] & [ "$(wattr wh $FW)" = "$fs_width $fs_height" ]; then
# restore size and position.
wtp $osp $FW
# remove atom from window.
atomx -d WM_FS $FW
else # if it's not atom and it's not in fullsize
# create atom and save original size and position.
atomx WM_FS="$(wattr xywh $FW)" $FW
# fullsize it.
wtp $x $y $fs_width $fs_height $FW
fi
}
case $FLAG in
-f)
fullsize
;;
-n)
north
wtp $x $y $w $h $FW
;;
-s)
south
wtp $x $y $w $h $FW
;;
-e)
est
wtp $x $y $w $h $FW
;;
-o)
west
wtp $x $y $w $h $FW
;;
-r) # rigth
wmv 10 0 $FW
;;
-l) # left
wmv -10 0 $FW
;;
-d) # down
wmv 0 10 $FW
;;
-u) # up
wmv 0 -10 $FW
;;
-w) # width -
wrs -10 0 $FW
;;
-W) # width +
wrs 10 0 $FW
;;
-h) # higth -
wrs 0 -10 $FW
;;
-H) # hight +
wrs 0 10 $FW
;;
*)
usage
;;
esac

View File

@ -1,48 +0,0 @@
#!/bin/sh
. /tmp/wms_var
## some info width dzen2 ##
FLAG=$1
clock() {
while true; do
date +%H:%M
sleep 60
done
}
# kill dzen
DZPID=$(pgrep dzen)
if [ -n "$DZPID" ]; then
pkill dzen
pkill wms_dz.sh
else
case $FLAG in
-c) # make a simple clock.
clock | dzen2 -fn Hack-80 \
-fg "#$BC" -bg "#$AC" \
-w 360 -h 120 -x 500 -y 300 \
&
;;
-f) # make a simple fetch.
sfetch.sh | dzen2 -fn Hack-14 \
-e 'onstart=uncollapse' -l 16 \
-fg "#$BC" -bg "#$AC" \
-w 960 -x 200 -y 160 -p \
&
;;
-s) # make a simple status.
status.sh | dzen2 -fn Hack-14 \
-e 'onstart=uncollapse' -l 7 \
-fg "#$BC" -bg "#$AC" \
-w 500 -x 420 -y 280 -p \
&
;;
*)
exit 0
;;
esac
fi

View File

@ -1,60 +0,0 @@
#!/bin/sh
## manage session and some more things ##
. /tmp/wms_var
# keybindings reload.
KBRELOAD="pkill -usr1 -x sxhkd"
# lock screen monitor.
LOCK="slock"
# poweroff monitor.
MOFF="xset dpms force off"
# suspend to ram.
SP="doas zzz -z"
# hibernate.
HB="doas zzz -Z"
# reboot.
RB="doas shutdown -r now"
# poweroff.
POFF="doas shutdown -h now"
# exit session.
EXIT="pkill wew"
# litle menu.
PROMPT="reload-key\nlock\nmonitor-off\nhalt\nreboot\nsuspend\nhibernate\nexit"
option=`echo $PROMPT | $XMENU`
if [ ${#option} -gt 0 ]; then
case $option in
reload-key)
$KBRELOAD
;;
lock)
$LOCK
;;
monitor-off)
$MOFF
;;
suspend)
$SP
;;
hibernate)
$HB
;;
halt)
$POFF
;;
reboot)
$RB
;;
exit)
$EXIT
;;
*)
;;
esac
else
exit 0
fi

View File

@ -1,18 +0,0 @@
#!/bin/bash
## toggle between terminals ##
. /tmp/wms_var
# terminal name.
TNAME=$(echo $TERMINAL | cut -d ' ' -f 1)
# print all windows, filter and target the first in stack.
TARGET=$(
for wid in $(lsw); do
printf '%s\n' "$wid $(atomx WM_CLASS $wid)"
done | grep "$TNAME" | cut -d ' ' -f 1 | head -n 1)
# focus terminal.
wms_mainrole.sh $TARGET

View File

@ -1,129 +1,146 @@
#!/bin/sh
## some layouts to order the windows ##
## move and resize windows ##
. /tmp/wms_var
. $HOME/.config/wms/wms_var
FLAG=$1
# focused window id.
FW=$(pfw)
# root window id.
RID=$(lsw -r)
# focused window.
FW=$(pfw)
# count maped windows.
CMW=$(lsw | wc -l)
# root width.
# root window width.
RW=$(wattr w $RID)
# root height.
# root window height.
RH=$(wattr h $RID)
# usable screen width.
# screen utilizable width.
SW=$((RW - 2 * BW))
# usable screen height.
# screen utilizable height.
SH=$((RH - 2 * BW))
usage() {
cat<<EOF
usage:
wms_usher.sh [ -m, -t, -w ]
-m) monucule
-t) tiled
-w) widespread
wms_usher.sh [ -n, -s, -e, -o, -r, -l, -d, -u, -w, -W, -h, -H ]
-f) fullsize
-n) half north
-s) half south
-e) half est
-o) half west
-r) move right
-l) move left
-d) move down
-u) move up
-w) resize width -
-W) resize width +
-h) resize height -
-H) resize height +
EOF
}
# all windows at full screen
monocule() {
for wid in $(lsw); do
wtp 0 0 $SW $SH $wid
done
# half north value
north() {
x=0
y=0
w=$SW
h=$((SH / 2 - BW))
}
# tiling. Master and stack
tiling() {
# screen widht width gaps added.
sw=$((RW - 2 * GAP - 2 * BW))
# master screen height.
msh=$((RH - 2 * GAP - 2 * BW))
# stack screen height (( - BW))?
ssh=$((RH - GAP))
# stack windows count.
swcount=$((CMW - 1))
# master area width.
mwidth=$((sw * MP / 100 - 2 * BW))
# master area height.
mheight=$msh
# master X coordinate.
mx=$GAP
# master Y coordinate.
my=$GAP
# stack width.
swidth=$((sw - mwidth - GAP - 2 * BW))
# stack height.
# half south value
south() {
x=0
y=$((SH / 2 + BW))
w=$SW
h=$((SH / 2))
}
# if swcount in 0 or not.
[ "$swcount" = "0" ] && sheight=ssh \
|| sheight=$((ssh / swcount - GAP - 2 * BW))
# half est value
est() {
x=$((SW / 2 + BW))
y=0
w=$((SW / 2))
h=$SH
}
# stack x coordinate.
sx=$((mwidth + 2 * GAP + 2 * BW))
# stack y coordinate.
sy=$GAP
# half west value
west() {
x=0
y=0
w=$((SW / 2 - BW))
h=$SH
}
if [ "$swcount" = "0" ]; then
wtp $mx $my $sw $msh $FW
else
# put focused window as master
wtp $mx $my $mwidth $mheight $FW
# fulsize function
fullsize() {
# original size and position.
osp=$(atomx WM_FS $FW)
# fullsize width.
fs_width=$((RW - BW * 2))
# fullsize height.
fs_height=$((RH - BW * 2))
x=0
y=0
# if atom exist and it is in fullsize
if [ -n "$osp" ] & [ "$(wattr wh $FW)" = "$fs_width $fs_height" ]; then
# restore size and position.
wtp $osp $FW
# remove atom from window.
atomx -d WM_FS $FW
# put the rest of the windows in stack
for wid in $(lsw | grep -v $FW); do
wtp $sx $sy $swidth $sheight $wid
# incremental stack Y coordinate.
sy=$((sy + sheight + GAP + 2 * BW))
done
else # if it's not atom and it's not in fullsize
# create atom and save original size and position.
atomx WM_FS="$(wattr xywh $FW)" $FW
# fullsize it.
wtp $x $y $fs_width $fs_height $FW
fi
}
# widespread
widespread() {
# windows width.
ww=$((SW * WP / 100))
# windows height.
wh=$((SH * WP / 100))
# initial X coordinate.
x=$(((RW - ww) / (CMW * 2)))
# initial Y coordinate.
y=$(((RH - wh) / (CMW * 2)))
# function X value.
xmax=$(((RW - ww) / CMW))
# function Y value.
ymax=$(((RH - wh) / CMW))
# put windows in cascade
for wid in $(lsw); do
wtp $x $y $ww $wh $wid
# incremental X value.
x=$((x + xmax))
# incremental Y value.
y=$((y + ymax))
done
}
# if there is a focused window.
if [ -n "$FW" ]; then
case $FLAG in
-m)
monocule
;;
-t)
tiling
;;
-w)
widespread
;;
*)
usage
;;
esac
fi
case $FLAG in
-f)
fullsize
;;
-n)
north
wtp $x $y $w $h $FW
;;
-s)
south
wtp $x $y $w $h $FW
;;
-e)
est
wtp $x $y $w $h $FW
;;
-o)
west
wtp $x $y $w $h $FW
;;
-r) # rigth
wmv 10 0 $FW
;;
-l) # left
wmv -10 0 $FW
;;
-d) # down
wmv 0 10 $FW
;;
-u) # up
wmv 0 -10 $FW
;;
-w) # width -
wrs -10 0 $FW
;;
-W) # width +
wrs 10 0 $FW
;;
-h) # higth -
wrs 0 -10 $FW
;;
-H) # hight +
wrs 0 10 $FW
;;
*)
usage
;;
esac

View File

@ -4,13 +4,13 @@
wew | while read ev wid args; do
case $ev in
MAP) # focus on mappng requests
wattr o $wid || wms_mainrole.sh -t
MAP) # focus on mappng requests.
wattr o $wid || wms_focuser.sh -t
;;
UNMAP) # focus the top window in the servers window stack
if [ ! "$(pfw)" ]; then
wms_mainrole.sh -t
fi
UNMAP) # focus the top window in the servers window stack.
[ ! "$(pfw)" ] && wms_focuser.sh -t
;;
esac
done