From 5a4d4a06a287985fbf5b458056881d3d0a0c71aa Mon Sep 17 00:00:00 2001 From: xero Date: Sun, 22 Jan 2017 23:22:55 -0500 Subject: add wmutils setup --- wmutils/.sxhkdrc | 94 ++++++++++++++++++++ wmutils/.xinitrc | 54 ++++++++++++ wmutils/bin/bar | 30 +++++++ wmutils/bin/clock | 27 ++++++ wmutils/bin/closest.sh | 38 ++++++++ wmutils/bin/deletelock.sh | 54 ++++++++++++ wmutils/bin/focus.sh | 57 ++++++++++++ wmutils/bin/fullscreen.sh | 41 +++++++++ wmutils/bin/group | 105 ++++++++++++++++++++++ wmutils/bin/groups.sh | 214 +++++++++++++++++++++++++++++++++++++++++++++ wmutils/bin/mon | 48 ++++++++++ wmutils/bin/pulse | 26 ++++++ wmutils/bin/rainbow.sh | 15 ++++ wmutils/bin/restart | 14 +++ wmutils/bin/snap.sh | 80 +++++++++++++++++ wmutils/bin/switch_grid.sh | 93 ++++++++++++++++++++ wmutils/bin/tile.sh | 39 +++++++++ wmutils/bin/tray | 37 ++++++++ wmutils/bin/wgrp | 192 ++++++++++++++++++++++++++++++++++++++++ wmutils/bin/wm | 45 ++++++++++ wmutils/bin/xwait | 15 ++++ wmutils/colors | 28 ++++++ 22 files changed, 1346 insertions(+) create mode 100644 wmutils/.sxhkdrc create mode 100644 wmutils/.xinitrc create mode 100755 wmutils/bin/bar create mode 100755 wmutils/bin/clock create mode 100755 wmutils/bin/closest.sh create mode 100755 wmutils/bin/deletelock.sh create mode 100755 wmutils/bin/focus.sh create mode 100755 wmutils/bin/fullscreen.sh create mode 100755 wmutils/bin/group create mode 100755 wmutils/bin/groups.sh create mode 100755 wmutils/bin/mon create mode 100755 wmutils/bin/pulse create mode 100755 wmutils/bin/rainbow.sh create mode 100755 wmutils/bin/restart create mode 100755 wmutils/bin/snap.sh create mode 100755 wmutils/bin/switch_grid.sh create mode 100755 wmutils/bin/tile.sh create mode 100755 wmutils/bin/tray create mode 100755 wmutils/bin/wgrp create mode 100755 wmutils/bin/wm create mode 100755 wmutils/bin/xwait create mode 100644 wmutils/colors diff --git a/wmutils/.sxhkdrc b/wmutils/.sxhkdrc new file mode 100644 index 0000000..3e6293c --- /dev/null +++ b/wmutils/.sxhkdrc @@ -0,0 +1,94 @@ +# start applications +mod4 + Return + urxvt + +#launcher +mod4 + w + interrobang + +# lock +mod4 + Escape + xscreensaver-command -lock + +# ==== manipulate windows ==== + +# restart +mod4 + R + ~/bin/restart + +# move +mod4 + {h,j,k,l} + wmv {-20 0,0 +20, 0 -20, +20 0} $(pfw) + +# resize +mod4 + shift + {h,j,k,l} + wrs {-20 0,0 +20, 0 -20, +20 0} $(pfw) + +# close window +mod4 + x + killw $(pfw) +# killw $(pfw) && lsw | sed 1q | xargs wtf + +# make fullscreen +mod4 + f + ~/bin/fullscreen.sh $(pfw) + +# put window back/forward +mod4 + l + chwso -i $(pfw) + +# cycle through windows +alt + {Tab, shift + Tab} + ~/focus.sh {next,prev} 2>/dev/null && \ + wmp -a $(wattr xy $(pfw)) && \ + wmp -r $(wattr wh $(pfw)) + +# focus the closest window in each direction +alt + {h,j,k,l} + ~/bin/closest.sh {h,j,k,l} + +# put windows to the corners +#mod4 + {y,u,b,n,g} +# ~/bin/corner.sh {tl,tr,bl,br,md} + +# tile windows +mod4 + t + ~/bin/tile.sh + +# ==== window groups ==== + +# next group +mod4 + n + wgrp -n + +# previous group +mod4 + p + wgrp -p + +# make group +mod4 + m + wgrp -m + +# delete group +mod4 + d + wgrp -d + +# add to group +mod4 + a + wgrp -a + +# remove from group +mod4 + r + wgrp -r + +# show all +mod4 + s + wgrp -s + +# add group +mod4 + 9 + wgrp -m + +# remove group +mod4 + 0 + wgrp -d diff --git a/wmutils/.xinitrc b/wmutils/.xinitrc new file mode 100644 index 0000000..3e0eaf8 --- /dev/null +++ b/wmutils/.xinitrc @@ -0,0 +1,54 @@ +#!/bin/sh + +exec 1>&2 2>/dev/null + +BOOTSTRAP=$(dirname `readlink -f $0`) +XRESOURCES=$BOOTSTRAP/xresources +PATH="$PATH:$BOOTSTRAP/bin" + +export XRESOURCES PATH BOOTSTRAP + +# merge custom x resources +xrdb -merge "${HOME}/.Xdefaults" & + +# custom keymappings +xmodmap ~/.xmodmap + +# terminal emulator +urxvtd -q -f -o & + +# compositing manager +compton -b --config ~/.config/compton.conf & + +# configure touchpad +syndaemon -i 0.8 -d & +if egrep -iq 'touchpad' /proc/bus/input/devices; then + synclient VertEdgeScroll=0 & + synclient TapButton1=1 & + synclient TapButton2=1 & + synclient TapButton3=2 & + synclient VertTwoFingerScroll=1 & + synclient HorizTwoFingerScroll=1 & +fi + +# keyboard settings - 250 ms delay and 25 cps (characters per second) repeat rate. +xset r rate 250 25 & + +# disable system beep +xset b off & + +# start the rock +mpd & + +# wallpaper +hsetroot -full ~/images/wallpaper/cyberpunk-5.png + +# default cursor +xsetroot -cursor_name left_ptr + +# hotkey daemon +sxhkd -c ~/.sxhkdrc & + +# ░▒▓█ wmutis █▓▒░ +~/bin/wm & +exec ~/bin/xwait diff --git a/wmutils/bin/bar b/wmutils/bin/bar new file mode 100755 index 0000000..22b498f --- /dev/null +++ b/wmutils/bin/bar @@ -0,0 +1,30 @@ +#!/bin/sh +# ██ +# ░██ +# ░██ ██████ ██████ +# ░██████ ░░░░░░██ ░░██░░█ +# ░██░░░██ ███████ ░██ ░ +# ░██ ░██ ██░░░░██ ░██ +# ░██████ ░░████████░███ +# ░░░░░ ░░░░░░░░ ░░░ +# +# ▓▓▓▓▓▓▓▓▓▓ +# ░▓ author ▓ xero +# ░▓ code ▓ http://code.xero.nu/dotfiles +# ░▓ mirror ▓ http://git.io/.files +# ░▓▓▓▓▓▓▓▓▓▓ +# ░░░░░░░░░░ +# +#█▓▒░ lemonbar wgrp display + +#f="-Gohu-GohuFont-Medium-R-Normal--11-80-100-100-C-60-ISO10646-1" +f=-*-Symbola-*-*-*-*-11-*-*-*-*-*-iso10646-* +fg='#ffd0d8e0' +bg='#ff111111' + +{ + while :; do + $@ + sleep 1 || break + done +} 2> /dev/null | lemonbar -d -p -g 55x16+157+0 -f $f -B $bg -F $fg diff --git a/wmutils/bin/clock b/wmutils/bin/clock new file mode 100755 index 0000000..2e45acd --- /dev/null +++ b/wmutils/bin/clock @@ -0,0 +1,27 @@ +#!/bin/sh +# ██ ██ +# ░██ ░██ +# █████ ░██ ██████ █████ ░██ ██ +# ██░░░██ ░██ ██░░░░██ ██░░░██░██ ██ +# ░██ ░░ ░██░██ ░██░██ ░░ ░████ +# ░██ ██ ░██░██ ░██░██ ██░██░██ +# ░░█████ ███░░██████ ░░█████ ░██░░██ +# ░░░░░ ░░░ ░░░░░░ ░░░░░ ░░ ░░ +# +# ▓▓▓▓▓▓▓▓▓▓ +# ░▓ author ▓ xero +# ░▓ code ▓ http://code.xero.nu/dotfiles +# ░▓ mirror ▓ http://git.io/.files +# ░▓▓▓▓▓▓▓▓▓▓ +# ░░░░░░░░░░ +# +#█▓▒░ lemonbar wgrp display + +f="-Gohu-GohuFont-Medium-R-Normal--11-80-100-100-C-60-ISO10646-1" +fg='#ffd0d8e0' +bg='#ff111111' + +while :; do + echo "%{c}$(date "+%H:%M %Y-%m-%d")%{c}" + sleep 1 || break +done | lemonbar -d -p -g 110x16+48+0 -f $f -B $bg -F $fg diff --git a/wmutils/bin/closest.sh b/wmutils/bin/closest.sh new file mode 100755 index 0000000..c49b8fb --- /dev/null +++ b/wmutils/bin/closest.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# +# z3bra - 2014 (c) wtfpl +# find and focus the closest window in a specific direction +# depends on: focus.sh + +# get current window id +CUR=$(pfw) + +usage() { + echo "usage: $(basename $0) " >&2 + exit 1 +} + +next_east() { + lsw | xargs wattr xi | sort -nr | sed "0,/$CUR/d" | sed "1s/^[0-9]* //p;d" +} + +next_west() { + lsw | xargs wattr xi | sort -n | sed "0,/$CUR/d" | sed "1s/^[0-9]* //p;d" +} + +next_north() { + lsw | xargs wattr yi | sort -nr | sed "0,/$CUR/d" | sed "1s/^[0-9]* //p;d" +} + +next_south() { + lsw | xargs wattr yi | sort -n | sed "0,/$CUR/d" | sed "1s/^[0-9]* //p;d" +} + +# Use the specification of your choice: WASD, HJKL, ←↑↓→, west/north/south/east +case $1 in + h|a|east|left) focus.sh $(next_east) 2>/dev/null ;; + j|s|south|down) focus.sh $(next_south) 2>/dev/null ;; + k|w|north|up) focus.sh $(next_north) 2>/dev/null ;; + l|d|west|right) focus.sh $(next_west) 2>/dev/null ;; + *) usage +esac diff --git a/wmutils/bin/deletelock.sh b/wmutils/bin/deletelock.sh new file mode 100755 index 0000000..ed9e553 --- /dev/null +++ b/wmutils/bin/deletelock.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# +# wildefyr - 2015 (c) wtfpl +# toggle delete lock for current window + +usage() { + echo "usage: $(basename $0) " + exit 1 +} + +wid=$(pfw) + +case $2 in + 0x*) + wid=$2 + ;; + *) + usage + ;; +esac + +case $1 in + lock) + xprop -id $wid -f _WMUTILS_DELETELOCK 8i -set _WMUTILS_DELETELOCK '1' + ;; + unlock) + xprop -id $wid -remove _WMUTILS_DELETELOCK + ;; + toggle) + lockStatus=$(xprop -id $wid _WMUTILS_DELETELOCK | cut -d\ -f 3) + case $lockStatus in + 1) + $(basename $0) unlock $wid + ;; + *) + $(basename $0) lock $wid + ;; + esac + ;; + status) + lockStatus=$(xprop -id $wid _WMUTILS_DELETELOCK | cut -d\ -f 3) + case $lockStatus in + 1) + echo "1" + ;; + *) + echo "0" + ;; + esac + ;; + *) + usage + ;; +esac diff --git a/wmutils/bin/focus.sh b/wmutils/bin/focus.sh new file mode 100755 index 0000000..7af3bc6 --- /dev/null +++ b/wmutils/bin/focus.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# +# z3bra (mods by xero) - 2014 (c) wtfpl +# window focus wrapper that sets borders and can focus next/previous window + +BW=${BW:-4} # border width +ACTIVE=${ACTIVE:-0xd0d0d0} # active border color +INACTIVE=${INACTIVE:-0x222222} # inactive border color + +# get current window id +CUR=$(pfw) + +usage() { + echo "usage: $(basename $0) " + exit 1 +} + +setborder() { + ROOT=$(lsw -r) + + # check if window exists + wattr $2 || return + + # do not modify border of fullscreen windows + test "$(wattr xywh $2)" = "$(wattr xywh $ROOT)" && return + + case $1 in + active) chwb -s $BW -c $ACTIVE $2 ;; + inactive) chwb -s $BW -c $INACTIVE $2 ;; + esac +} + +case $1 in + next) wid=$(lsw|grep -v $CUR|sed '1 p;d') ;; + prev) wid=$(lsw|grep -v $CUR|sed '$ p;d') ;; + 0x*) wattr $1 && wid=$1 ;; + *) usage ;; +esac + +# exit if we can't find another window to focus +test -z "$wid" && echo "$(basename $0): can't find a window to focus" >&2 && exit 1 + +if echo `wname $wid` | grep -q "stalonetray" +then + wmv -a 0 0 $wid + chwb -x 0x222222 -s 0 $wid + ignw -s $wid +else + setborder inactive $CUR # set inactive border on current window + setborder active $wid # activate the new window + chwso -r $wid # put it on top of the stack + wtf $wid # set focus on it +fi + +# you might want to remove this for sloppy focus +#wmp -a $(wattr xy $wid) # move the mouse cursor to +#wmp -r $(wattr wh $wid) # .. its bottom right corner diff --git a/wmutils/bin/fullscreen.sh b/wmutils/bin/fullscreen.sh new file mode 100755 index 0000000..497e560 --- /dev/null +++ b/wmutils/bin/fullscreen.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# +# z3bra - 2014 (c) wtfpl +# toggle the fullscreen state of a window +# depends on: focus.sh + +# this file is used to store the previous geometry of a window +FSFILE=${FSFILE:-~/.fwin} + +# it's pretty simple, but anyway... +usage() { + echo "usage: $(basename $0) " + exit 1 +} + +# exit if no argument given +test -z "$1" && usage + +# this will unset the fullscreen state of any fullscreen window if there is one. +# this way, there will only be one window in fullscreen at a time, and no window +# will loose their previous geometry info +test -f $FSFILE && wtp $(cat $FSFILE) + +# if file exist and contain our window id, it means that out window is in +# fullscreen mode +if test -f $FSFILE && grep -q $1 $FSFILE; then + # if the window we removed was our window, delete the file, so we can + # fullscreen it again later + rm -f $FSFILE + +else + # if not, then put the current window in fullscreen mode, after saving its + # geometry and id to $FSFILE we also remove any border from this window. + wattr xywhi $1 > $FSFILE + wtp $(wattr xywh `lsw -r`) $1 + chwb -s 0 $1 +fi + +# now focus the window, and put it in front, no matter which state we're in, and +# put the cursor on its bottom-right corner (for consistency) +focus.sh $1 diff --git a/wmutils/bin/group b/wmutils/bin/group new file mode 100755 index 0000000..0d105dc --- /dev/null +++ b/wmutils/bin/group @@ -0,0 +1,105 @@ +#!/bin/sh +# +# wmg by: +# +# ▓█████▄ ▄████▄ ▄▄▄ ▄▄▄█████▓ +# ▒██▀ ██▌▒██▀ ▀█ ▒████▄ ▓ ██▒ ▓▒ +# ░██ █▌▒▓█ ▄ ▒██ ▀█▄ ▒ ▓██░ ▒░ +# ░▓█▄ ▌▒▓▓▄ ▄██▒░██▄▄▄▄██░ ▓██▓ ░ +# ░▒████▓ ▒ ▓███▀ ░ ▓█ ▓██▒ ▒██▒ ░ +# ▒▒▓ ▒ ░ ░▒ ▒ ░ ▒▒ ▓▒█░ ▒ ░░ +# ░ ▒ ▒ ░ ▒ ▒ ▒▒ ░ ░ +# ░ ░ ░ ░ ░ ▒ ░ +# ░ ░ ░ ░ ░ +# ░ ░ + +GRP_DIR="/tmp/wmutils/groups" +USE_FIFO=yes + +setup() { + [ -d "$GRP_DIR" ] || mkdir -p $GRP_DIR + if [ -n "$USE_FIFO" ] + then + [ -p "$GRP_DIR/.fifo" ] || mkfifo $GRP_DIR/.fifo + fi +} + +sed_apply() { + TMP=`mktemp /tmp/grp.XXXXXX` + sed $1 < $2 > $TMP && mv $TMP $2 || rm $TMP + [ -n "$DEBUG" ] && echo "sed $1 < $2 > $TMP && mv $TMP $2 || rm $TMP" +} + +pop() { + sed_apply "/$1/d" $2 +} + +push() { + echo $1 >> $GRP_DIR/$2 +} + +view() { + while read WID + do mapw -m $WID + done < $GRP_DIR/$1 +} + +hide() { + while read WID + do mapw -u $WID + done < $GRP_DIR/$1 +} + +pop_from_all() { + for GRP in $GRP_DIR/* + do + pop $1 $GRP + done +} + +case $1 in +view) + setup + if [ -f "$GRP_DIR/$2" ] + then + for GRP in $GRP_DIR/* + do hide `basename $GRP` + done + view $2 + else + echo "group does not exist" + exit 1 + fi + + # customize your fifo printing here + if [ -n "$USE_FIFO" ] + then + for GRP in $GRP_DIR/* + do + GRP_BASE="`basename $GRP`" + GRP_NUM=`wc -l < $GRP | tr -cd '[:digit:]'` + [ $GRP_NUM -ne 0 ] && printf '^fg(#888)' || printf '^fg(#555)' + [ $GRP_BASE -eq $2 ] && printf '^fg(orange)<' + printf "$GRP_BASE^fg()" + [ $GRP_BASE -eq $2 ] && printf '>^fg()' + done > $GRP_DIR/.fifo + echo >> $GRP_DIR/.fifo + fi + + ;; +hide) + setup + hide $2 + ;; +add) + setup + pop_from_all $2 + push $2 $3 + hide $3 + view $3 + ;; +remove) + setup + pop_from_all $2 + ;; +esac diff --git a/wmutils/bin/groups.sh b/wmutils/bin/groups.sh new file mode 100755 index 0000000..486c5a7 --- /dev/null +++ b/wmutils/bin/groups.sh @@ -0,0 +1,214 @@ +#!/bin/sh +# +# Copyright (c) 2015 Greduan , licensed under the WTFPL +# Adds group-like capabilities, sorta like those you find in CWM and such WMs + +usage() { + cat << EOF +usage: $(basename $0) [-hCU] [-c wid] [-s wid group] [-tmMu group] + -h shows this help + -c cleans WID from group files (and makes it visible) + -C runs cleanup routine + -s sets WID's group + -t toggle group visibility state + -m maps (shows) group + -M maps group and unmaps all other groups + -u unmaps (hides) group + -U unmaps all the groups +EOF + + exit 1 +} + +# test for no arguments +test $# -eq 0 && usage + +# I suggest it's under /tmp or somewhere that gets cleaned up at reboot or gets +# cleaned up after X stops running +FSDIR=${FSDIR:-/tmp/groups.sh} + +# define our functions + +# clean WID ($1) from group files +clean_wid() { + # TODO: make POSIX compatible, -i is a GNU-ism + sed -i "/$1/d" $FSDIR/group.* +} + +# cleans group ($1) from (in)active files +clean_status() { + # TODO: make POSIX compatible, -i is a GNU-ism + sed -i "/$1/d" $FSDIR/active + sed -i "/$1/d" $FSDIR/inactive +} + +# shows all the windows in group ($1) +map_group() { + # safety + if ! grep -q $1 < $FSDIR/all; then + echo "Group doesn't exist" + exit 1 + fi + + # clean statuses + clean_status $1 + # add to active + echo $1 >> $FSDIR/active + + # loop through group and map windows + while read line; do + mapw -m $line + done < $FSDIR/group.$1 +} + +# hides all the windows in group ($1) +unmap_group() { + # safety + if ! grep -q $1 < $FSDIR/all; then + echo "Group doesn't exist" + exit 1 + fi + + # clean statuses + clean_status $1 + # add to inactive + echo $1 >> $FSDIR/inactive + + # loop through group and unmap windows + while read line; do + mapw -u $line + done < $FSDIR/group.$1 +} + +# assigns WID ($1) to the group ($2) +set_group() { + # make sure we've no duplicates + clean_wid $1 + clean_status $2 + + # insert WID into new group if not already there + grep -q $1 < $FSDIR/group.$2 || \ + echo $1 >> $FSDIR/group.$2 + + # if we can't find the group add it to groups and make it active + grep -q $2 < $FSDIR/all || \ + echo $2 >> $FSDIR/all && \ + echo $2 >> $FSDIR/active + + # map WID if group is active + grep -q $2 < $FSDIR/active && \ + mapw -m $1 + + # unmap WID if group is inactive + grep -q $2 < $FSDIR/inactive && \ + mapw -u $1 +} + +# toggles visibility state of all the windows in group ($1) +toggle_group() { + # safety + if ! grep -q $1 < $FSDIR/all; then + echo "Group doesn't exist" + return + fi + + # search through active groups first + grep -q $1 < $FSDIR/active && \ + unmap_group $1 && \ + return + + # search through inactive groups next + grep -q $1 < $FSDIR/inactive && \ + map_group $1 && \ + return +} + +# removes all the unexistent WIDs from groups +# removes all group files that don't exist +# removes from 'all' file all groups that don't exist +cleanup_everything() { + # clean WIDs that don't exist + # using `cat` instead of `<` because error suppression + cat $FSDIR/group.* 2>/dev/null | while read wid; do + wattr $wid || \ + clean_wid $wid + done + + # clean group files that are empty + for file in $FSDIR/group.*; do + # is the group empty? + if [ ! -s $file ]; then + rm -f $file + fi + done + + # remove groups that don't exist from 'all' + while read line; do + if [ ! -f $FSDIR/group.$line ]; then + # TODO: make POSIX compatible, -i is a GNU-ism + sed -i "/$line/d" $FSDIR/all + clean_status $line + fi + done < $FSDIR/all +} + +# actual run logic (including arguments and such) + +# check $FSDIR exists +test -d $FSDIR || mkdir -p $FSDIR + +# touch all the files +test -f $FSDIR/active || :> $FSDIR/active +test -f $FSDIR/inactive || :> $FSDIR/inactive +test -f $FSDIR/all || :> $FSDIR/all + +cleanup_everything + +# getopts yo +while getopts "hc:Cs:t:m:M:u:U" opt; do + case $opt in + h) + usage + ;; + c) + clean_wid $OPTARG + mapw -m $OPTARG + break + ;; + C) + cleanup_everything + break + ;; + s) + set_group $OPTARG $(eval echo "\$$OPTIND") + break + ;; + t) + toggle_group $OPTARG + break + ;; + m) + map_group $OPTARG + break + ;; + M) + for file in $FSDIR/group.*; do + group=${file##*.} + unmap_group $group + done + map_group $OPTARG + break + ;; + u) + unmap_group $OPTARG + break + ;; + U) + for file in $FSDIR/group.*; do + group=${file##*.} + unmap_group $group + done + break + ;; + esac +done diff --git a/wmutils/bin/mon b/wmutils/bin/mon new file mode 100755 index 0000000..82b5f7d --- /dev/null +++ b/wmutils/bin/mon @@ -0,0 +1,48 @@ +#!/bin/sh +# +# ██████████ ██████ ███████ +# ░░██░░██░░██ ██░░░░██░░██░░░██ +# ░██ ░██ ░██░██ ░██ ░██ ░██ +# ░██ ░██ ░██░██ ░██ ░██ ░██ +# ███ ░██ ░██░░██████ ███ ░██ +# ░░░ ░░ ░░ ░░░░░░ ░░░ ░░ +# + +usage() { + echo "usage: $(basename $0) [-lr ]\n -l list monitor ids\n -r get resolution by id\n" >&2 + exit 1 +} + +list() { + mons=`xrandr | grep -e "^.* connected" | cut -d " " --field "1"` + for mon in $mons; do + echo "$mon" + done +} + +res() { + [ -z $1 ] && usage + res=`xrandr\ + | grep -e "^$1 connected"\ + | cut --delimiter=' ' --fields='3'\ + | sed "s/[x\+]/ /g"` + echo $res +} + +while getopts "lr:" opt +do + case $opt in + # list + l) + list + ;; + # res + r) + res $OPTARG + ;; + *) + usage + ;; + esac +done +[ -z $1 ] && usage diff --git a/wmutils/bin/pulse b/wmutils/bin/pulse new file mode 100755 index 0000000..156c044 --- /dev/null +++ b/wmutils/bin/pulse @@ -0,0 +1,26 @@ +#!/bin/sh +# ██ +# ██████ ░██ +#░██░░░██ ██ ██ ░██ ██████ █████ +#░██ ░██░██ ░██ ░██ ██░░░░ ██░░░██ +#░██████ ░██ ░██ ░██░░█████ ░███████ +#░██░░░ ░██ ░██ ░██ ░░░░░██░██░░░░ +#░██ ░░██████ ███ ██████ ░░██████ +#░░ ░░░░░░ ░░░ ░░░░░░ ░░░░░░ +# +FREQ=${FREQ:-0.05} +FILE=$BOOTSTRAP/colors +COLORS=$(tac < $FILE | cat - $FILE | tr -d '#') + +while :; do + for c in $COLORS + do + CUR=$(pfw) + test "`wattr wh $CUR`" != "`wattr wh $(lsw -r)`" && chwb -c $c $CUR + for WIN in `lsw` + do + test "$WIN" != "$CUR" && chwb -c 0x222222 $WIN + done + sleep $FREQ + done +done diff --git a/wmutils/bin/rainbow.sh b/wmutils/bin/rainbow.sh new file mode 100755 index 0000000..5bb91ab --- /dev/null +++ b/wmutils/bin/rainbow.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# +# z3bra - 2015 (c) wtfpl +# make the current window "rainbowish"... Awesome idea from xero@nixers.net ! + +FREQ=${FREQ:-0.1} +COLORS="888888 8064cc 6480cc 64cccc 80cc64 cccc64 cc6464" +CUR=$(pfw) + +while :; do + for c in $COLORS; do + chwb -c $c $(pfw) + sleep $FREQ + done +done diff --git a/wmutils/bin/restart b/wmutils/bin/restart new file mode 100755 index 0000000..6571b93 --- /dev/null +++ b/wmutils/bin/restart @@ -0,0 +1,14 @@ +#!/bin/sh + +rm -rf /tmp/wmutils +killall sxhkd +killall pnmixer +killall np-applet +killall clipit +killall stalonetray +killall urxvt +killall urxvtc +killall pulse +killall wm +killall xwait +startx diff --git a/wmutils/bin/snap.sh b/wmutils/bin/snap.sh new file mode 100755 index 0000000..6089ff1 --- /dev/null +++ b/wmutils/bin/snap.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# +# wmutils/contrib>: snap.sh, 9/12/15 kekler +# snaps focued window to the left, right, top, or bottom edge + +usage() { + echo "usage: $(basename $0) " >&2 + exit 1 +} + +# default values for gaps and master area +TOP_PANEL=${PANEL:-20} +GAP=${GAP:-5} + +# get current window id and its borderwidth +PFW=$(pfw) +BW=$(wattr b $PFW) + +# get root window's size +ROOT=$(lsw -r) +SW=$(wattr w $ROOT) +SH=$(wattr h $ROOT) + +# calculate usable screen size (without borders and gaps) +SH=$((SH - TOP_PANEL)) + +snap_up() +{ + wtp $GAP $((GAP + TOP_PANEL)) $((SW - 2*GAP - 2*BW)) $((SH/2 - 2*BW - GAP - GAP/2)) $PFW +} + +snap_right() +{ + wtp $((SW - SW/2 + GAP/2)) $((GAP + TOP_PANEL)) $((SW/2 - 2*BW - GAP - GAP/2)) $((SH - 2*BW - 2*GAP)) $PFW +} + +snap_down() +{ + wtp $GAP $((SH - SH/2 + GAP/2 + TOP_PANEL)) $((SW - 2*GAP - 2*BW)) $((SH/2 - 2*BW - GAP - GAP/2)) $PFW +} + +snap_left() +{ + wtp $GAP $((GAP + TOP_PANEL)) $((SW/2 - 2*BW - GAP - GAP/2)) $((SH - 2*BW - 2*GAP)) $PFW +} + +HSW=$((SW/2 - 2*BW - GAP - GAP/2)) +HSH=$((SH/2 - 2*BW - GAP - GAP/2)) + +snap_tr() +{ + wtp $((SW - SW/2 + GAP/2)) $((GAP + TOP_PANEL)) $HSW $HSH $PFW +} + +snap_br() +{ + wtp $((SW - SW/2 + GAP/2)) $((SH - SH/2 + GAP/2 + TOP_PANEL)) $HSW $HSH $PFW +} + +snap_tl() +{ + wtp $GAP $((GAP + TOP_PANEL)) $HSW $HSH $PFW +} + +snap_bl() +{ + wtp $GAP $((SH - SH/2 + GAP/2 + TOP_PANEL)) $HSW $HSH $PFW +} + +case $1 in + h|a|east|left) snap_left ;; + j|s|south|down) snap_down ;; + k|w|north|up) snap_up ;; + l|d|west|right) snap_right ;; + tr|northeast) snap_tr ;; + br|southeast) snap_br ;; + tl|northwest) snap_tl ;; + bl|southwest) snap_bl ;; +esac + diff --git a/wmutils/bin/switch_grid.sh b/wmutils/bin/switch_grid.sh new file mode 100755 index 0000000..a7aa66d --- /dev/null +++ b/wmutils/bin/switch_grid.sh @@ -0,0 +1,93 @@ +#!/bin/sh +# +# Copyright (c) 2015 Greduan , licensed under the WTFPL license +# Credit where credit is due, the grid algorithm was written by z3bra +# +# When used puts all the windows in a grid and when you focus one of the windows +# it puts all the windows back to their original location and focuses the window +# you switched to. +# depends on: wew focus.sh + +TEMP=$(mktemp) && wattr xywhi $(lsw) > $TEMP +NB=$(wc -l < $TEMP) # NB as in NumBer of windows + +# just safety +if [ $NB -eq 1 ]; then + exit +fi + +# user defined +BW=${BW:-4} # width of your borders +GAP=${GAP:-20} # gap between windows + +# get monitor dimensions +ROOT=$(lsw -r) +SW=$(wattr w $ROOT) +SH=$(wattr h $ROOT) +# reduce screen useable screen area to improve later expressions +SW=$(( SW - GAP - 2*BW )) +SH=$(( SH - GAP - 2*BW )) + +# calculate the size of the grid using the square root of the number of windows +ROWS=$(echo "sqrt($NB)" | bc) +COLS=$ROWS + +# FOLLOWING WAS WRITTEN BY Z3BRA, don't give me credit for this awesome logic +# for each row... +for r in `seq 1 $ROWS`; do + + # .. if we're on the last row, display all the remaining windows + # eg: if we have 12 windows, the square root would be 3 (truncated). + # so the script would draw a 3x3 grid. This would leave 3 windows apart. To + # avoid this, we set the number of columns of the last row as + # + # 12 - 3 * (3-1) + # => 12 - 3 * 2 + # => 12 - 6 + # == 6 + # so we will have 6 windows on the last row, instead of 3. + # This do not lead to the best looking grid, I know (the best one would be + # 3x4), but it's the simplest algo I've found. Don't forget we're playing + # with shell scripts here, not matlab.. + test $r -eq $ROWS && COLS=$(( NB - ROWS * (ROWS-1) )) + + # for each column of each row.. + for c in `seq 1 $COLS`; do + + # exit if we don't have other windows to display + test $(( (r-1)*r + c )) -gt $NB && break + + # heigh of windows (total heigh minus gaps and borders) + H=$(( SH/ROWS - GAP - BW )) + # same for width + W=$(( SW/COLS - GAP - BW )) + + # and the tricky part.. + # The X offset is the width * the actual column (starting from 0) + the + # gaps/borders multiplied by the column number (draw it on a sheet of + # paper like me, it will make much more sense! + X=$(( W * (c-1) + c*(GAP + BW) )) + # same for the Y offset + Y=$(( H * (r-1) + r*(GAP + BW) )) + + # finally, teleport the window to the place we just calculated. + # the sed trick is used to get the corresponding line number in the file + # holding the window infos. + wtp $X $Y $W $H $(sed "$(( (r-1)*r + c ))p;d" $TEMP | cut -d\ -f5) + done +done +# END Z3BRA + +# listen to wew for our desired event +wew -m 4 | while IFS=: read ev wid; do + if [ $ev -eq 4 ]; then + while read line; do + wtp $line + done < $TEMP + focus.sh $wid + killall wew + fi +done + +# cleanup +rm $TEMP diff --git a/wmutils/bin/tile.sh b/wmutils/bin/tile.sh new file mode 100755 index 0000000..2b89960 --- /dev/null +++ b/wmutils/bin/tile.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# +# z3bra - 2014 (c) wtfpl +# arrange windows in a tiled pattern + +# default values for gaps and master area +PANEL=${PANEL:-0} +GAP=${GAP:-20} +MASTER=${MASTER:-900} + +# get current window id and its borderwidth +PFW=$(pfw) +BW=$(wattr b $PFW) + +# get root window's size (beware, multi-head setups...) +ROOT=$(lsw -r) +SW=$(wattr w $ROOT) +SH=$(wattr h $ROOT) + +# get the number of windows to put in the stacking area +MAX=$(lsw|grep -v $PFW|wc -l) + +# calculate usable screen size (without borders and gaps) +SW=$((SW - GAP - 2*BW)) +SH=$((SH - GAP - 2*BW - PANEL)) + +Y=$((0 + GAP + PANEL)) +# put current window in master area +wtp $GAP $Y $((MASTER - GAP - 2*BW)) $((SH - GAP)) $PFW + +# and now, stack up all remaining windows on the right +X=$((MASTER + GAP)) +W=$((SW - MASTER - GAP)) +H=$((SH / MAX - GAP - 2*BW)) + +for wid in $(lsw|grep -v $PFW); do + wtp $X $Y $W $H $wid + Y=$((Y + H + GAP + 2*BW)) +done diff --git a/wmutils/bin/tray b/wmutils/bin/tray new file mode 100755 index 0000000..0573640 --- /dev/null +++ b/wmutils/bin/tray @@ -0,0 +1,37 @@ +#!/bin/sh +# ██ +# ░██ +# ██████ ██████ ██████ ██ ██ +# ░░░██░ ░░██░░█ ░░░░░░██ ░░██ ██ +# ░██ ░██ ░ ███████ ░░███ +# ░██ ░██ ██░░░░██ ░██ +# ░░██ ░███ ░░████████ ██ +# ░░ ░░░ ░░░░░░░░ ██ +# ░░ + +#stalonetray -c ~/.stalonetrayrc & +stalonetray --kludges fix_window_pos --dockapp-mode simple --geometry 1x1+165 & +# force position and ignore that ▄█▀ █▬█ █ ▀█▀ +trayid=`lsw` +wmv -a 165 0 $trayid +chwb -x 0x222222 -s 0 $trayid +ignw -s $trayid + +# keyring +gnome-keyring-daemon & + +# wifi +/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 & +nm-applet & + +# power management +xfce4-power-manager & + +# sound mixer +pnmixer & + +# volume keys +xfce4-volumed & + +# clipboard manager +clipit & diff --git a/wmutils/bin/wgrp b/wmutils/bin/wgrp new file mode 100755 index 0000000..c242260 --- /dev/null +++ b/wmutils/bin/wgrp @@ -0,0 +1,192 @@ +#!/bin/sh +# +# ███ ██ █████ ██████ ██████ +#░░██ █ ░██ ██░░░██░░██░░█░██░░░██ +# ░██ ███░██░██ ░██ ░██ ░ ░██ ░██ +# ░████░████░░██████ ░██ ░██████ +# ███░ ░░░██ ░░░░░██░███ ░██░░░ +#░░░ ░░░ █████ ░░░ ░██ +# ░░░░░ ░░ + +# tmp dir +wmutilsdir=${wmutilsdir:-"/tmp/wmutils"} +dir="$wmutilsdir/groups" +# create if it doesnt exist +if [ ! -d "$dir" ] +then + mkdir -p "$dir" + printf "1\n" > "$dir/active" + cat "/dev/null" > "$dir/1" +fi + +# get current group +active=`cat "$dir/active"` + +# help +usage() { + say "usage: `basename $0` [-lbsmdarnpRA ]\n\ + -l list groups\n\ + -b status bar info\n\ + -s show all\n\ + -m make group\n\ + -d delete group\n\ + -n next group\n\ + -p previous group\n\ + -a add current window\n\ + -A add by wid\n\ + -r remove current window\n\ + -R remove by wid" +} + +say() { + printf "$@\n" >&2 + exit 1 +} + +show() { + while read wid + do + mapw -m "$wid" + done <"$1" +} + +hide() { + while read wid + do + mapw -u "$wid" + done <"$1" +} + +bar() { + b=" " + for grp in `ls "$dir" | grep -E '[0-9]'` + do + if [ "$grp" == "$active" ] + then + b="$b ◆" + else + b="$b ◇" + fi + done + printf "$b \n" +} + +ingroup() { + grep -q "$1" "$dir/$active" +} + +pushpop() { + if [ "$1" == "add" ] + then + if ingroup $2 + then + say "error: window already exists in group" + else + printf "$2\n" >> "$dir/$active" + fi + else + if ingroup $2 + then + sed -i "/$2/d" "$dir/$active" + else + say "error: window does not exist in group" + fi + fi +} + +while getopts "lbsmdarnpiR:A:" opt +do + case $opt in + # list + l) + tree $dir + ;; + # bar + b) + bar + ;; + # show all + s) + lsw -u | while read wid + do + mapw -m "$wid" + done + ;; + # make group + m) + last=`ls -r "$dir" | grep -E '[0-9]' | head -n 1` + next=$((last+1)) + cat "/dev/null" > "$dir/$next" + ;; + # delete group + d) + if [ `ls -r "$dir" | grep -E '[0-9]' | wc -l` -gt 1 ] + then + rm "$dir/$active" + ls "$dir" | grep -E '[0-9]' | head -n 1 > "$dir/active" + else + say "there must be at least one group" + fi + ;; + # next group + n) + hide "$dir/$active" + for grp in `ls "$dir" | grep -E '[0-9]'` + do + if [ "$grp" -gt "$active" ] + then + printf "$grp\n" > "$dir/active" + break + fi + done + if [ "$grp" -eq "$active" ] + then + grp=`ls "$dir" | grep -E '[0-9]' | head -n 1` + printf "$grp\n" > "$dir/active" + fi + active=`cat "$dir/active"` + show "$dir/$active" + ;; + # previous group + p) + hide "$dir/$active" + for grp in `ls -r "$dir" | grep -E '[0-9]'` + do + if [ "$grp" -lt "$active" ] + then + printf "$grp\n" > "$dir/active" + break + fi + done + if [ "$grp" -eq "$active" ] + then + grp=`ls -r "$dir" | grep -E '[0-9]' | head -n 1` + printf "$grp\n" > "$dir/active" + fi + active=`cat "$dir/active"` + show "$dir/$active" + ;; + # add window to group + a) + pushpop "add" `pfw` + ;; + # add window to group by id + A) + pushpop "add" $OPTARG + ;; + # remove window from group + r) + pushpop "rm" `pfw` + ;; + # remove window from group + R) + pushpop "rm" $OPTARG + ;; + # unknown option + *) + usage + ;; + esac +done + +[ $# -eq 0 ] && usage diff --git a/wmutils/bin/wm b/wmutils/bin/wm new file mode 100755 index 0000000..2124a6b --- /dev/null +++ b/wmutils/bin/wm @@ -0,0 +1,45 @@ +#!/bin/sh +# ██ ██ ██ +# ░██ ░░ ░██ +# ███ ██ ██████████ ██ ██ ██████ ██ ░██ ██████ +#░░██ █ ░██░░██░░██░░██░██ ░██░░░██░ ░██ ░██ ██░░░░ +# ░██ ███░██ ░██ ░██ ░██░██ ░██ ░██ ░██ ░██░░█████ +# ░████░████ ░██ ░██ ░██░██ ░██ ░██ ░██ ░██ ░░░░░██ +# ███░ ░░░██ ███ ░██ ░██░░██████ ░░██ ░██ ███ ██████ +#░░░ ░░░ ░░░ ░░ ░░ ░░░░░░ ░░ ░░ ░░░ ░░░░░░ + + +wmutilsdir="/tmp/wmutils" +mkdir -p "$wmutilsdir/window" +cat "/dev/null" > "$wmutilsdir/window/active" + +~/bin/tray & +~/bin/clock & +~/bin/wgrp -m & +~/bin/bar 'wgrp -b' & +~/bin/pulse & + +wew | while IFS=: read ev wid; do + wattr o $wid && continue + case $ev in + # enter/leave + 7) + echo "$(wname "$wid")" > "$wmutilsdir/window/active" + ;; + # create + 16) + echo "$(wname "$wid")" > "$wmutilsdir/window/active" + ;; + # close + 18) + ~/bin/focus.sh prev 2>/dev/null + ~/bin/wgrp -R $wid 2>/dev/null + echo "$(wname `pfw`)" > "$wmutilsdir/window/active" + ;; + # window map + 19) + echo "$(wname "$wid")" > "$wmutilsdir/window/active" + ~/bin/focus.sh $wid + ;; + esac +done diff --git a/wmutils/bin/xwait b/wmutils/bin/xwait new file mode 100755 index 0000000..9980e3a --- /dev/null +++ b/wmutils/bin/xwait @@ -0,0 +1,15 @@ +#!/bin/sh +# ██ ██ +# ░░ ░██ +# ██ ██ ███ ██ ██████ ██ ██████ +#░░██ ██ ░░██ █ ░██ ░░░░░░██ ░██░░░██░ +# ░░███ ░██ ███░██ ███████ ░██ ░██ +# ██░██ ░████░████ ██░░░░██ ░██ ░██ +# ██ ░░██ ███░ ░░░██░░████████░██ ░░██ +#░░ ░░ ░░░ ░░░ ░░░░░░░░ ░░ ░░ +# +# yes, this is pointless loop to hold x open :P + +while :; do + sleep 10 +done diff --git a/wmutils/colors b/wmutils/colors new file mode 100644 index 0000000..5e508e6 --- /dev/null +++ b/wmutils/colors @@ -0,0 +1,28 @@ +#171717 +#191919 +#222222 +#2c2c2c +#303030 +#373737 +#3e3e3e +#464646 +#4c4c4c +#535353 +#5a5a5a +#616161 +#696969 +#6f6f6f +#767676 +#7e7e7e +#848484 +#8c8c8c +#939393 +#9a9a9a +#a1a1a1 +#a8a8a8 +#aeaeae +#b8b8b8 +#bdbdbd +#c4c4c4 +#cccccc +#cecece -- cgit v1.2.1