corrections in comments

This commit is contained in:
#root_informatica 2024-01-21 00:05:04 -03:00
parent d2072bb357
commit 9dbe1ebba4
18 changed files with 307 additions and 153 deletions

31
batlarm.sh Executable file
View file

@ -0,0 +1,31 @@
#!/bin/sh
## alternating window border colors depending on battery charge ##
## this script depends on power.sh which is in the /others repo ##
. /tmp/wms_var
# freq.
FREQ=0.5
# alternate colors.
COLORS="aa0000 $AC"
while true:; do
# battery status.
read -r STATUS < /sys/class/power_supply/BAT0/status
# if status discharging.
if [ "$STATUS" = "Discharging" ]; then
# alternate border colors.
for c in $COLORS; do
chwb -c $c $(pfw)
sleep $FREQ
done
else # if not
# default border colors.
chwb -c $AC $(pfw)
# exit loop.
break
fi
done

View file

@ -6,31 +6,49 @@
. /tmp/wms_var
FLAG=$1
FW=$(pfw) # focused window
RID=$(lsw -r) # root widnow id
BID=$(lsw -o) # bachground window id
RW=$(wattr w $RID) # root width
RH=$(wattr h $RID) # root height
SW=$((RW - 2 * BW)) # usable screen width
SH=$((RH - 2 * BW)) # usable screen height
# focused window.
FW=$(pfw)
# root window id.
RID=$(lsw -r)
# background window id.
BID=$(lsw -o)
# 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))
# send windows to background
background() {
atomx WM_IGN="$(wattr xywh $FW) $FW" $FW # store size and place in atom
chwso -l $FW # put on bottom in window stack order
wtp 0 0 $SW $SH $FW # fullsize
ignw -s $FW # ignore focused window
chwb -c $BC $FW # change border color to ignore
wms_mainrole.sh -p # focus prev window
# store size and place of the focused widnow in atom.
atomx WM_IGN="$(wattr xywh $FW) $FW" $FW
# put it on bottom in window stack order.
chwso -l $FW
# make fullsize.
wtp 0 0 $SW $SH $FW
# ignore focused window.
ignw -s $FW
# change border color to BC.
chwb -c $BC $FW
# focus prev window.
wms_mainrole.sh -p
}
# restore windows from background
restore() {
ignw -r $BID # unignore
wtp $(atomx WM_IGN $BID) # restore size and place
chwso -r $BID # put on top in the window stack order
atomx -d WM_IGN $BID # delete atom
wms_mainrole.sh $BID # focus
# unignore.
ignw -r $BID
# restore size an d place.
wtp $(atomx WM_IGN $BID)
# put it on top in the window stack order.
chwso -r $BID
# delete atom.
atomx -d WM_IGN $BID
# focus it.
wms_mainrole.sh $BID
}
if [ -n "$BID" ]; then

View file

@ -5,18 +5,26 @@
. /tmp/wms_var
FLAG=$1
FW=$(pfw) # focused window
CL=$(atomx WM_CL $FW) # clearrer atom
AMW=$(lsw) # all maped windows
UW=$(atomx WM_CL $(lsw -u)) # unmaped windows
# fucused window.
FW=$(pfw)
# clearer atom.
CL=$(atomx WM_CL $FW)
# all maped windows.
AMW=$(lsw)
# unmaped widnows.
UW=$(atomx WM_CL $(lsw -u))
if [ -n "$UW" ]; then # if unmaped windows
mapw -m $UW # map them
atomx -d WM_CL $UW # delete atom
# if unmaped windows exist.
if [ -n "$UW" ]; then
# map them.
mapw -m $UW
# delete atom.
atomx -d WM_CL $UW
else # if no unmaped windows
for wid in $(lsw); do
atomx WM_CL=$wid $wid
done # create atom
mapw -u $AMW # unmap windows
else # if no unmaped windows
# unmaped them and create atom.
for wid in $(lsw); do
atomx WM_CL=$wid $wid
done
mapw -u $AMW
fi

View file

@ -5,10 +5,11 @@
. /tmp/wms_var
TARGET=$(for wid in $(lsw); do
# 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,6 @@
. /tmp/wms_var
$TERMINAL -name 'xlauncher' \
$TERMINAL -name 'wms_launcher' \
-g $GEOMETRY \
-bg "#$BC" \
-e bash -c 'cmd=$(compgen -c | sort -u | grep -v fzf | fzf --bind 'ctrl-e:print-query' --no-sort); setsid -f $cmd'

View file

@ -5,6 +5,7 @@
. /tmp/wms_var
FLAG=$1
# focused window.
FW=$(pfw)
usage() {
@ -62,6 +63,7 @@ esac
# transfer focus
wtf $wid
# set borders
chwb -s $BW -c $IC $(lsw | grep -v $(pfw)) # unfocused color
chwb -s $BW -c $AC $(pfw) # focused color
# set colors on the unfocused windows.
chwb -s $BW -c $IC $(lsw | grep -v $(pfw))
# set colors on the focused widnow.
chwb -s $BW -c $AC $(pfw)

View file

@ -2,7 +2,6 @@
. /tmp/wms_var
$TERMINAL -name "xmenu" \
$TERMINAL -name "wms_menu" \
-g $GEOMETRY \
-bg "#$BC" \
-e "fzf --bind 'ctrl-e:print-query' --no-sort $* < /proc/$$/fd/0 > /proc/$$/fd/1"

View file

@ -1,10 +1,15 @@
#!/bin/sh
TMPIMG="/tmp/mimic.png" # temp image target
TMPCOL="/tmp/tmpcol" # temp extracted colors file
WMSVAR="$HOME/.config/wms/wms_var" # window manager variables
XVAR="$HOME/.Xresources" # default x variable file
NC="3" # number of colors to extract
# temp image target.
TMPIMG="/tmp/mimic.png"
# temp extracted colors file.
TMPCOL="/tmp/tmpcol"
# window manager variables.
WMSVAR="$HOME/.config/wms/wms_var"
# default x variables file.
XVAR="$HOME/.Xresources"
# number of colors to extract.
NC="3"
# spy on what's on the desktop
import -w root $TMPIMG

View file

@ -4,13 +4,19 @@
. /tmp/wms_var
FLAG=$1 # flag
FW=$(pfw) # focused window id
RID=$(lsw -r) # root window id
RW=$(wattr w $RID) # root window width
RH=$(wattr h $RID) # root window heigth
SW=$((RW - 2 * BW - 2 * GAP)) # screen utilizable width
SH=$((RH - 2 * BW - 2 * GAP)) # screen utilizable height
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
@ -66,28 +72,33 @@ west() {
# fulsize function
fullsize() {
fs=$(atomx WM_FS $FW) # atom fullsize and original size position
fs_width=$((RW - BW * 2)) # fullsize width
fs_height=$((RH - BW * 2)) # fullsize height
# 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 "$fs" ] & [ "$(wattr wh $FW)" = "$fs_width $fs_height" ]; then
wtp $fs $FW # restore size and position
atomx -d WM_FS $FW # remove atom from window
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
atomx WM_FS="$(wattr xywh $FW)" $FW # create atom and save original size an position
wtp $x $y $fs_width $fs_height $FW # 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
wtp $x $y $w $h $FW
;;
-n)
north

View file

@ -15,26 +15,26 @@ clock() {
# kill dzen
DZPID=$(pgrep dzen)
if [ -n "$DZPID" ]; then # if pid exist
pkill dzen # kill'em all
if [ -n "$DZPID" ]; then
pkill dzen
pkill wms_dz.sh
else
case $FLAG in
-c)
-c) # make a simple clock.
clock | dzen2 -fn Hack-80 \
-fg "#$BC" -bg "#$AC" \
-w 360 -h 120 -x 500 -y 300 \
&
;;
-f)
-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)
-s) # make a simple status.
status.sh | dzen2 -fn Hack-14 \
-e 'onstart=uncollapse' -l 7 \
-fg "#$BC" -bg "#$AC" \

View file

@ -4,29 +4,41 @@
. /tmp/wms_var
INPUT=$1 # input
FW=$(pfw) # focused window
SW=$(wattr w $(lsw -r)) # screen width
SH=$(wattr h $(lsw -r)) # screen height
WW=$((SW * 80 / 100)) # windows width = 80% of the screen
WH=$((SH * 80 / 100)) # windows height = 80% of the screen
MAXX=$((SW - WW)) # max X coordinate
MAXY=$((SH - WH)) # max Y coordinate
FREQ=20 # refresh frequency
FLAG=$1
# focused window.
FW=$(pfw)
# screen width.
SW=$(wattr w $(lsw -r))
# screen height.
SH=$(wattr h $(lsw -r))
# windows width = 80% of the screen.
WW=$((SW * 80 / 100))
# windows height = 80% of the screen.
WH=$((SH * 80 / 100))
# max X coordinate.
MAXX=$((SW - WW))
# max Y coordinate.
MAXY=$((SH - WH))
# refresh freq.
FREQ=20
usage() {
echo "usage:
cat<<EOF
usage:
wms_screensaver.sh [ -a, -f ]
-a) all windows
-f) focused window"
-f) focused window
EOF
}
# random movement for all windowsaver
all_win() {
while true; do
for wid in $(lsw); do
x=$(shuf -i 0-$MAXX -n 1) # random x coordinate
y=$(shuf -i 0-$MAXY -n 1) # random y coordinate
# random x coordinate.
x=$(shuf -i 0-$MAXX -n 1)
# random y coordinate.
y=$(shuf -i 0-$MAXY -n 1)
wtp $x $y $WW $WH $wid
done
sleep $FREQ

View file

@ -4,14 +4,24 @@
. /tmp/wms_var
KBRELOAD="pkill -usr1 -x sxhkd" # keybindings reload
LOCK="slock" # lock screen monitor
MOFF="xset dpms force off" # poweroff monitor
SP="doas zzz -z" # suspend to RAM
HB="doas zzz -Z" # hibernate
RB="doas shutdown -r now" # reboot
POFF="doas shutdown -h now" # poweroff
EXIT="pkill sxhkd; pkill wew" # exit session
# 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`

View file

@ -4,9 +4,12 @@
. /tmp/wms_var
FLAG=$1 # input
FW=$(pfw) # focused window id
AMW=$(lsw) # all maped windows
FLAG=$1
# focused window id.
FW=$(pfw)
# all maped windows.
AMW=$(lsw)
# names file path.
NAMES="$HOME/.config/wms/wms_names"
usage() {
@ -54,15 +57,20 @@ del_all() {
# togle groups
togle() {
herds=$(atomx WM_HERD $(lsw -a) | cut -d ' ' -f1 | sort -u) # herds
if [ -n "$herds" ]; then # check if any herd exist
h_target=$(printf "$herds" | $XMENU) # select herd target
wind_to_map=$(atomx WM_HERD $(lsw -u) | grep $h_target | cut -d ' ' -f2) # windows to map
wind_to_unmap=$(atomx WM_HERD $(lsw) | grep -v $h_target | cut -d ' ' -f2) # windows to unmap
# herds.
herds=$(atomx WM_HERD $(lsw -a) | cut -d ' ' -f1 | sort -u)
# check if any herd exist.
if [ -n "$herds" ]; then
# select herd target.
h_target=$(printf "$herds" | $XMENU)
# windwos to map.
wind_to_map=$(atomx WM_HERD $(lsw -u) | grep $h_target | cut -d ' ' -f2)
# windows to unmap.
wind_to_unmap=$(atomx WM_HERD $(lsw) | grep -v $h_target | cut -d ' ' -f2)
# do it.
mapw -m $wind_to_map & mapw -u $wind_to_unmap
fi
}
case $FLAG in
-a)

View file

@ -4,12 +4,16 @@
. /tmp/wms_var
AMW=$(lsw) # all maped windows
# all maped widnows.
AMW=$(lsw)
# delay.
DELAY=.2
# if any maped window exist.
if [ -n "$AMW" ]; then
# print id, class and name in xmenu.
TARGET=$(\
for wid in $(lsw); do # print id, class and name in xmenu
for wid in $(lsw); do
printf '%s\n' "$wid | $(atomx WM_CLASS $wid) | $(wname $wid)"
done | cut -c 1-100 | $XMENU | cut -d '|' -f 1)

View file

@ -4,11 +4,14 @@
. /tmp/wms_var
TARGET=$(pfw) # focused window
# focused windows.
TARGET=$(pfw)
# names file path.
NAMES="$HOME/.config/wms/wms_names"
if [ "$(atomx WM_CLASS $TARGET)" = "$TERMINAL" ]; then # if any terminal is focused
atomx WM_NAME="$($XMENU < $NAMES)" $TARGET # change atom name
# if any terminal is focused.
if [ "$(atomx WM_CLASS $TARGET)" = "$TERMINAL" ]; then
# change atom name.
atomx WM_NAME="$($XMENU < $NAMES)" $TARGET
fi

View file

@ -4,12 +4,15 @@
. /tmp/wms_var
TNAME=$(echo $TERMINAL | cut -d ' ' -f 1) # terminal name
# 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 # print all windows, filter and target the first in stack
for wid in $(lsw); do
printf '%s\n' "$wid $(atomx WM_CLASS $wid)"
done | grep "$TNAME" | cut -d ' ' -f 1 | head -n 1)
wms_mainrole.sh $TARGET # focus terminal
# focus terminal.
wms_mainrole.sh $TARGET

View file

@ -4,14 +4,21 @@
. /tmp/wms_var
FLAG=$1 # input
RID=$(lsw -r) # root window id
FW=$(pfw) # focused window
CMW=$(lsw | wc -l) # count maped windows
RW=$(wattr w $RID) # root width
RH=$(wattr h $RID) # root height
SW=$((RW - 2 * BW)) # usable screen width
SH=$((RH - 2 * BW)) # usable screen height
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))
usage() {
cat<<EOF
@ -32,18 +39,30 @@ monocule() {
# tiling. Master and stack
tiling() {
sw=$((RW - 2 * GAP - 2 * BW)) # screen widht width gaps added
msh=$((RH - 2 * GAP - 2 * BW)) # master screen height
ssh=$((RH - GAP)) # stack screen height ((- BW))?
swcount=$((CMW - 1)) # stack windows count
mwidth=$((sw * MP / 100 - 2 * BW)) # master area width
mheight=$msh # master area height
mx=$GAP # master x coordinate
my=$GAP # master y coordinate
swidth=$((sw - mwidth - GAP - 2 * BW)) # stack width
sheight=$((ssh / swcount - GAP - 2 * BW)) # stack height
sx=$((mwidth + 2 * GAP + 2 * BW)) # stack x coordinate
sy=$GAP # stack y coordinate
# 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.
sheight=$((ssh / swcount - GAP - 2 * BW))
# stack x coordinate.
sx=$((mwidth + 2 * GAP + 2 * BW))
# stack y coordinate.
sy=$GAP
# put focused window as master
wtp $mx $my $mwidth $mheight $FW
@ -51,28 +70,38 @@ tiling() {
# put the rest of the windows in stack
for wid in $(lsw | grep -v $FW); do
wtp $sx $sy $swidth $sheight $wid
sy=$((sy + sheight + GAP + 2 * BW)) # incremental stack y coordinate
# incremental stack Y coordinate.
sy=$((sy + sheight + GAP + 2 * BW))
done
}
# widespread
widespread() {
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
# 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
x=$((x + xmax)) # incremental X value
y=$((y + ymax)) # incremental Y value
# incremental X value.
x=$((x + xmax))
# incremental Y value.
y=$((y + ymax))
done
}
if [ -n "$FW" ]; then # if there is a focused window
# if there is a focused window.
if [ -n "$FW" ]; then
case $FLAG in
-m)
monocule

View file

@ -8,10 +8,13 @@ else
. /tmp/wms_var
fi
FLAG=$1 # input
RID=$(lsw -r) # root window id
FW=$(pfw) # focused window
WMSVAR="/tmp/wms_var" # variable temporary file
FLAG=$1
# root window id.
RID=$(lsw -r)
# focused window.
FW=$(pfw)
# variable temporary file.
WMSVAR="/tmp/wms_var"
usage() {
cat<<EOF
@ -29,20 +32,23 @@ wms_revalue.sh [ -b, -B, -d, -g, -G, -m, -M, -w, -W]
EOF
}
# increase border. (+2 pixels)
border_inc() {
if [ $BW -le 10 ]; then
sed -i "s/^.*\bBW=\b.*$/BW=$((BW + 2))/" $WMSVAR
wms_mainrole.sh $FW
fi
} # +2 pixel calculation
}
# decrease border. (-2 pixels)
border_dec() {
if [ $BW -ge 4 ]; then
sed -i "s/^.*\bBW=\b.*$/BW=$((BW - 2))/" $WMSVAR
wms_mainrole.sh $FW
fi
} # -2 pixel calculation
}
# increase gaps. (+2 pixels)
gap_inc() {
if [ $GAP -le 40 ]; then
sed -i "s/^.*\bGAP=\b.*$/GAP=$((GAP + 2))/" $WMSVAR
@ -50,6 +56,7 @@ gap_inc() {
fi
}
# decrease gaps. (-2 pixels)
gap_dec() {
if [ $GAP -ge 2 ]; then
sed -i "s/^.*\bGAP=\b.*$/GAP=$((GAP - 2))/" $WMSVAR
@ -57,61 +64,65 @@ gap_dec() {
fi
}
# increase master area. (+5 pixels)
master_inc() {
if [ $MP -le 80 ]; then
sed -i "s/^.*\bMP=\b.*$/MP=$((MP + 5))/" $WMSVAR
wms_usher.sh -t
fi
} # 5% + calculation
}
# decrease master area. (-5 pixels)
master_dec() {
if [ $MP -ge 20 ]; then
sed -i "s/^.*\bMP=\b.*$/MP=$((MP - 5))/" $WMSVAR
wms_usher.sh -t
fi
} # 5% - calculation
}
# increase window percentage. (+5 %)
windowperc_inc() {
if [ $WP -le 90 ]; then
sed -i "s/^.*\bWP=\b.*$/WP=$((WP + 5))/" $WMSVAR
wms_usher.sh -w
fi
} # 5% + calculation
}
# decrease window percentage. (-5 %)
windowperc_dec() {
if [ $WP -ge 60 ]; then
sed -i "s/^.*\bWP=\b.*$/WP=$((WP - 5))/" $WMSVAR
wms_usher.sh -w
fi
} # 5% - calculation
}
if [ -n "$FLAG" ]; then
case $FLAG in
-b) # decrease border width
-b)
border_dec
;;
-B) # increase border width
-B)
border_inc
;;
-d) # load defaults
cp $HOME/.config/wms/wms_var /tmp/wms_var
;;
-g) # decrease gaps
-g)
gap_dec
;;
-G) # increase gaps
-G)
gap_inc
;;
-m) # reduce tiling master area
-m)
master_dec
;;
-M) # increase tiling master area
-M)
master_inc
;;
-w) # reduce window size
-w)
windowperc_dec
;;
-W) # increase window size
-W)
windowperc_inc
;;
*)