Skip to content

Instantly share code, notes, and snippets.

@97-109-107
Last active April 25, 2019 13:14
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 97-109-107/cc31c630fb261fca4e2f to your computer and use it in GitHub Desktop.
Save 97-109-107/cc31c630fb261fca4e2f to your computer and use it in GitHub Desktop.
This scipt can emulate a drop down terminal behaviour with any kind of emulator (or application). The same can be achieved without an external script, but won't work if you have differently sized workspaced - hence the resize and repositioning calls. The script assumes that the you have a statusbar of 18px height on top of your workspace (see ba…
#!/usr/bin/env python
import i3
import re
import sys
from time import sleep
import json
#resize <grow|shrink> <direction> [<px> px [or <ppt> ppt]]
barHeight = 18
tree = str(i3.get_tree());
def positionWindow():
i3.scratchpad("show", instance="metask")
workspace = [ws for ws in i3.get_workspaces() if ws['focused']][0]
screen_w =str(workspace['rect']['width'])
screen_h =str(workspace['rect']['height'])
targetheight = str(workspace['rect']['height']/3)
current = i3.filter(nodes=[], focused=True)
i3.command("move","absolute","position","0",str(barHeight))
i3.command("resize","shrink","width",screen_w);
i3.command("resize","shrink","height",screen_h);
i3.command("resize","grow","width",screen_w);
i3.command("resize","grow","height",targetheight);
#look for an entity that has the unique name of a scratchpad
m = re.search("metask", tree)
#if not found, spawn a new one
if(m == None):
i3.exec('urxvt -name metask')
sleep(0.11)
positionWindow();
else:
positionWindow();
for_window [instance="metask"] floating enable;
for_window [instance="metask"] move scratchpad; [instance="metask"] scratchpad show; move scratchpad
bindsym $mod+Escape exec i3-quaketerm-spawn-if.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment