Skip to content

Instantly share code, notes, and snippets.

@Brottweiler
Last active June 6, 2024 21:06
Show Gist options
  • Save Brottweiler/f3001a228cd20b6d43a51ea59bdeed52 to your computer and use it in GitHub Desktop.
Save Brottweiler/f3001a228cd20b6d43a51ea59bdeed52 to your computer and use it in GitHub Desktop.
Open a terminal with a selection box

Requirements

  • Your terminal emulator of choice
  • slop

Termite

termite --geometry=$(slop)

Make sure size_hints is set to false.

NOTE: --geometry was removed. Unsure if something will replace it.

xterm & st

#!/bin/bash
set -euf

read -r X Y W H < <(slop --bordersize 3 --format "%x %y %w %h" --tolerance 0 --quiet) && return

if [[ -n $W ]] || [[ -n $H ]]
then
	# Width and Height in px need to be converted to columns/rows
	# To get these magic values, make a fullscreen terminal, and divide your screen width by ${tput cols}, height by ${tput lines}
	(( W /= 6 ))
	(( H /= 13 ))
	g=${W}x${H}+${X}+${Y}
	# Uncomment your terminal of choice.
	xterm -geometry "$g"
	# st -g "$g" -t "Simple Terminal"
fi

Script above assumes a 1080p monitor.


References
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment