Skip to content

Instantly share code, notes, and snippets.

@Brottweiler
Last active May 23, 2020 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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.

st

#!/usr/bin/env bash
read -r X Y W H < <(slop -f "%x %y %w %h" -q)

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 st, and divide your screen width by ${tput cols}, height by ${tput lines}
    (( W /= 6 ))
    (( H /= 10 ))
    g=${W}x${H}+${X}+${Y}
    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