From c876995c2a4a398ef57f5b5fbcbb54fc0e5a572c Mon Sep 17 00:00:00 2001 From: horhik Date: Wed, 9 Sep 2020 16:51:58 +0300 Subject: [PATCH] add user scripts --- .local/bin/alacritty-colorscheme | 8 +++++++ .local/bin/disable_main_display | 3 +++ .local/bin/fullscreen-daemon | 25 +++++++++++++++++++++ .local/bin/imgt | 38 ++++++++++++++++++++++++++++++++ .local/bin/scratchpad.sh | 12 ++++++++++ 5 files changed, 86 insertions(+) create mode 100755 .local/bin/alacritty-colorscheme create mode 100755 .local/bin/disable_main_display create mode 100755 .local/bin/fullscreen-daemon create mode 100644 .local/bin/imgt create mode 100755 .local/bin/scratchpad.sh diff --git a/.local/bin/alacritty-colorscheme b/.local/bin/alacritty-colorscheme new file mode 100755 index 0000000..788bb11 --- /dev/null +++ b/.local/bin/alacritty-colorscheme @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from alacritty_colorscheme.cli import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.local/bin/disable_main_display b/.local/bin/disable_main_display new file mode 100755 index 0000000..ae4c1a9 --- /dev/null +++ b/.local/bin/disable_main_display @@ -0,0 +1,3 @@ +#!/bin/bash + + xrandr --output eDP1 --off; bspc monitor HDMI1 -d 1 2 3 4 5 6 7 8 9 0 "#" diff --git a/.local/bin/fullscreen-daemon b/.local/bin/fullscreen-daemon new file mode 100755 index 0000000..2eb9f68 --- /dev/null +++ b/.local/bin/fullscreen-daemon @@ -0,0 +1,25 @@ +#!/bin/sh +# depends on: xprop +# prevent certain window classes from being fullscreen in bspwm. +# define WM_CLASS blockers here: +blockers='chromium libreoffice firefox Firefox firefox-developer-edition MozillaWindowClass' + +bspc subscribe node_state | while read msg monitorId desktopId nodeId state value; do + # only care about fullscreens + [ "$state $value" = "fullscreen on" ] || continue + + # only act if the lock is off, also remove the lock if it exists. + if [ -f /tmp/bspcblock ]; then + rm /tmp/bspcblock + continue + fi + + # get info + class=$(xprop -id $nodeId | grep "WM_CLASS" | sed 's/^[^=]*=//g') + + # check all the blockers, toggle last state if encountered anywhere in WM_CLASS line. + IFS=' ' + for check in $blockers; do + echo $class | grep -q "\"$check\"" && bspc node $nodeId -t ~fullscreen & + done +done diff --git a/.local/bin/imgt b/.local/bin/imgt new file mode 100644 index 0000000..543ed7b --- /dev/null +++ b/.local/bin/imgt @@ -0,0 +1,38 @@ +#!/bin/bash +# +# Based on script by z3bra -- 2014-01-21 + +W3MIMGDISPLAY="/usr/lib/w3m/w3mimgdisplay" +FONTH=15 # Size of one terminal row +FONTW=7 # Size of one terminal column + +X=$1 +Y=$2 +COLUMNS=$3 +LINES=$4 +FILENAME=$5 + +read width height <<< `echo "5;$FILENAME" | $W3MIMGDISPLAY` +if [ -z "$width" -o -z "$height" ]; then + echo 'Error: Failed to obtain image size.' + exit 1 +fi + +x=$((FONTW * X)) +y=$((FONTH * Y)) + +max_width=$((FONTW * COLUMNS)) +max_height=$((FONTH * LINES)) + +if [ "$width" -gt "$max_width" ]; then + height=$((height * max_width / width)) + width=$max_width +fi +if [ "$height" -gt "$max_height" ]; then + width=$((width * max_height / height)) + height=$max_height +fi + +w3m_command="0;1;$x;$y;$width;$height;;;;;$FILENAME\n4;\n3;" + +echo -e "$w3m_command" | $W3MIMGDISPLAY diff --git a/.local/bin/scratchpad.sh b/.local/bin/scratchpad.sh new file mode 100755 index 0000000..507ece4 --- /dev/null +++ b/.local/bin/scratchpad.sh @@ -0,0 +1,12 @@ +#!/usr/bin/bash + +if [ -z $1 ]; then + echo "Usage: $0