initial commit

This commit is contained in:
rootniformaticaservice 2023-03-06 15:08:25 -03:00
commit 18c17a7fe1
13 changed files with 583 additions and 0 deletions

9
rwm.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
xrdb -merge .Xresources &
sxhkd &
wallpaper.sh &
exec rwm_voyeur.sh

40
rwm_focus.sh Executable file
View file

@ -0,0 +1,40 @@
#!/bin/sh
. $HOME/.config/rootwm/rwm_var
usage() {
echo "usage:
rwm_starship.sh [ -n, -p, -l, wid ]
-n) next in order stack
-p) prev in order stack
-t) focus the top window in the servers window stack
wid) window id"
}
case $1 in
-n) # focus next in stack order
wid=$(lsw | grep -v $(pfw) | sed '1 p;d')
chwso -r $wid
;;
-p) # focus prev in stack order
wid=$(lsw | grep -v $(pfw) | sed '$ p;d')
chwso -r $wid
;;
-t) # focus the top window in the servers window stack
wid=$(lsw | sed '$ p;d')
;;
0x*) # focus on wid
wattr $1 && wid=$1
chwso -r $wid
;;
*)
usage
;;
esac
# transfer focus
wtf $wid
# set borders
chwb -s $BW -c $BG $(lsw | grep -v $(pfw)) # unfocused color
chwb -s $BW -c $FG $(pfw) # focused color

22
rwm_fullsize.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/sh
. $HOME/.config/rootwm/rwm_var
FW=$(pfw) # focused window
RW=$(wattr w $(lsw -r)) # root width
RH=$(wattr h $(lsw -r)) # root height
WFW=$((RW - BW * 2)) # window fullsize width
WFH=$((RH - BW * 2)) # window fullsize heigh
TWF="/tmp/rwm_fullsize-$FW" # temporal window file
# if it is in the list and it is in fullsize
if [ -f "$TWF" ] & [ "$(wattr wh $FW)" = "$WFW $WFH" ]; then
wtp $(cat $TWF) $FW # restore size and position
rm $TWF # remove from list
else # if it's not in the list and it's not in fullsize
echo "$(wattr xywh $FW)" > $TWF # gets on the list
wtp 0 0 $WFW $WFH $FW # gets fullsize
fi

51
rwm_groups.sh Executable file
View file

@ -0,0 +1,51 @@
#!/bin/sh
. $HOME/.config/rootwm/rwm_var
NAMES=$(cat $HOME/.config/rootwm/names) # disponible names
FLAG=$1 # input
FW=$(pfw) # focused window id
AMW=$(lsw) # all maped windows
usage() {
echo "usage:
rwm_groups.sh [ -a, -r, -t ]
-a) add
-A) add all
-d) delete
-D) delete all
-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
utarget=$(for wid in $(lsw -u); do # unmaped targets
printf '%s\n' "$wid $(atomx WM_GROUP $wid)" | grep $gtarget
done)
mtarget=$(for wid in $(lsw); do # maped targets
if [ -n "$(atomx WM_GROUP $wid)" ]; then
printf '%s\n' "$wid $(atomx WM_GROUP $wid)" | grep -v $gtarget
fi
done)
mapw -m $utarget & mapw -u $mtarget # map utargets and unmap mtargets
fi
;;
*)
usage # self-explained
;;
esac

64
rwm_layout.sh Executable file
View file

@ -0,0 +1,64 @@
#!/bin/sh
. $HOME/.config/rootwm/rwm_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
usage() {
echo "usage:
rwm_layout.sh [ -m, -t, -w ]
-m) monucule
-t) tiled
-w) widespread"
}
if [ -n "$FW" ]; then
case $FLAG in
-m) # all windows at full screen
for wid in $(lsw); do
wtp 0 0 $SW $SH $wid
done
;;
-t) # 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 # focused window in 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
;;
-w) # 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
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
;;
*)
usage
;;
esac
fi

47
rwm_moveresize.sh Executable file
View file

@ -0,0 +1,47 @@
#!/bin/sh
FLAG=$1 # option
FW=$(pfw) # focused window
usage() {
echo "usage:
rwm_moveresize.sh [ -r, -l, -d, -u, -w, -W, -h, -H ]
-r) move right
-l) move left
-d) move down
-u) move up
-w) resize width -
-W) resize width +
-h) resize height -
-H) resize height +"
}
case $FLAG in
-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

40
rwm_session.sh Executable file
View file

@ -0,0 +1,40 @@
#!/bin/sh
. $HOME/.config/rootwm/rwm_var
LOCK="slock" # lock screen monitor
MOFF="xset dpms force off" # poweroff monitor
HB="doas pm-hibernate" # hibernate
RB="doas shutdown -r now" # reboot
POFF="doas shutdown -h now" # poweroff
EXIT="pkill wew && pkill sxhkd" # exit session
PROMPT="lock\nmonitor-off\nhalt\nreboot\nsuspend\nlogout"
option=`echo $PROMPT | $XMENU`
if [ ${#option} -gt 0 ]; then
case $option in
lock)
$LOCK
;;
monitor-off)
$MOFF
;;
suspend)
$HB
;;
halt)
$POFF
;;
reboot)
$RB
;;
logout)
$EXIT
;;
*)
;;
esac
else
exit 0
fi

47
rwm_settings.sh Executable file
View file

@ -0,0 +1,47 @@
#!/bin/sh
. $HOME/.config/rootwm/rwm_var
FLAG=$1
RID=$(lsw -r) # root window id
usage() {
echo "usage:
rwm_setting.sh [ -m, -M ]
-m) minimize tiling master area
-M) maximize tiling master area"
}
mp=$(atomx WM_MP $RID)
master_in() {
atomx WM_MP=$((mp + 5)) $RID
rwm_layout.sh -t
}
master_dec() {
atomx WM_MP=$((mp - 5)) $RID
rwm_layout.sh -t
}
if [ -n "$FLAG" ]; then
case $FLAG in
-m) # minimize tiling master area
master_dec
;;
-M) # maximize tiling master area
master_in
;;
*)
usage
;;
esac
else
atomx WM_NAME=$NAME $RID
atomx WM_MP=$MP $RID
fi

11
rwm_switchfocus.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
. $HOME/.config/rootwm/rwm_var
TARGET=$(\
for wid in $(lsw); do # print id, class and name in xmenu
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_starship.sh "$TARGET" # focus target

12
rwm_terminalrename.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/sh
. $HOME/.config/rootwm/rwm_var
TARGET=$(pfw) # focused window
NAMES=$(cat $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
fi

13
rwm_terminaltogle.sh Executable file
View file

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

14
rwm_voyeur.sh Executable file
View file

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

213
sxhkdrc_example Executable file
View file

@ -0,0 +1,213 @@
####################################
######## wm independent hotkeys ###################################
####################################
# reload hotkeys ##
# session ##
super + shift + e
rwm_session.sh
########################
########## 1 to 9 ##################################
########################
# open
super + 0
xopen.sh
# status ##
super + 1
root_status.sh
# browser ##
super + 2
xlinks.sh
# musicplayer ##
super + 3
musicplayer.sh
# podcastplayer ##
super + 4
podcastplayer.sh
# clock ##
super + 5
xclock.sh
# capturemedia ##
super + 6
capturemedia.sh
# rainbow ##
super + 7
rainbow.sh
# fetch ##
super + 8
root_fetch.sh
# keymap ##
super + 9
herbe_status.sh
####################
########## tools ############################################
####################
# terminal/focus ##
super + Return
xterm -bc -ti vt340
# rename terminal ##
super + r
rwm_terminalrename.sh
# togle
super + Tab
rwm_terminaltogle.sh
#################################################
# program launcher ##
super + {_,shift +}Menu
{xlauncher.sh, dmenu_run.sh}
####################################
# proces ##
super + period
proces.sh
#################################
# volume ##
XF86AudioRaiseVolume
volup.sh
XF86AudioLowerVolume
voldown.sh
XF86AudioMute
xterm -e alsamixer
###################################################
# screenshot ##
Print
screenshot.sh
################################################
# copi to clipboard ##
super + x
xtoclip.sh
###############################
# lock screen ##
super + BackSpace
slock
#############################
######### manage windows ########################################
#############################
# maximize ##
super + f
rwm_maximize.sh
# monocule layout ##
super + m
rwm_layout.sh -m
# tilling layout ##
super + t
rwm_layout.sh -t
# maximize master area
super + {dead_acute,ccedilla}
rwm_settings.sh {-m,-M}
# widespread layout ##
super + w
rwm_layout.sh -w
##################################################################
# kill ##
super + {_,shift +}q
{killw $(pfw),pkill $(wname $(pfw))}
# switch focus ##
super + space
rwm_switchfocus.sh
# focus next/prev ##
super + {n,p}
rwm_starship.sh {-n,-p}
# zzz ##
super + {_,shift + }z
{windowsaver.sh,windowblur.sh}
########################################################################################
# move ##
super + {l,h,j,k}
rwm_moveresize.sh {-r,-l,-d,-u}
# resize ##
super + shift + {l,h,j,k}
rwm_moveresize.sh {-W,-w,-H,-h}
# warp ##
alt + {y,u,b,n}
wmv -a {0 0,1280 0,0 800,1280 800} $(pfw)
#######################
########## groups ######################
######################
# add focused window / all windows to group ##
super + {_,shift + }a
rwm_groups.sh {-a,-A}
# delete focused window / all windows from group ##
super + {_,shift +}d
rwm_groups.sh {-d,-D}
# map / unmap groups ##
super + g
rwm_groups.sh -t
######################
########## mourse ##########################################
######################
# mose click ##
# super + {8,9,0}
# xdotool click {1,2,3}
################################
# mouse move relative left ##
super + {_,shift + }Left
wmp -{r -- -20 0,r -- -200 0}
# mouse move relative right ##
super + {_,shift + }Right
wmp -{r 20 0,r 200 0}
# mouse move relative up ##
super + {_,shift + }Up
wmp -{r 0 -20,r 0 -200}
# mouse move relative down ##
super + {_,shift + }Down
wmp -{r 0 20,r 0 200}
# mouse banish ##
super + b
wmp 1280 800