Last active
August 29, 2015 14:05
-
-
Save flacjacket/774937040bb93f51e930 to your computer and use it in GitHub Desktop.
Vagrant files for cairocffi w/ xcffib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.swp | |
.vagrant | |
__pycache__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Updating apt-get" | |
sudo apt-get update > /dev/null | |
echo "Installing necessary packages" | |
sudo apt-get install -qq git xvfb python-pip libcairo2 > /dev/null | |
echo "Installing extra stuff for xcffib...." | |
sudo apt-get install -qq build-essential python-dev libffi-dev libxcb1-dev libxcb-render0-dev libgdk-pixbuf2.0-0 shared-mime-info > /dev/null | |
echo "Installing py.test from PyPi" | |
sudo pip install pytest > /dev/null | |
if [ -d cairocffi ]; then | |
echo "Cairocffi already checkedout" | |
else | |
echo "Checking out cairocffi" | |
git clone -b xcb-testing git://github.com/flacjacket/cairocffi.git > /dev/null | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import libqtile.layout | |
import libqtile.bar | |
import libqtile.command | |
import libqtile.widget | |
import libqtile.config | |
auto_fullscreen = True | |
groups = [ | |
libqtile.config.Group("a"), | |
libqtile.config.Group("b"), | |
libqtile.config.Group("c"), | |
libqtile.config.Group("d") | |
] | |
layouts = [ | |
libqtile.layout.stack.Stack(num_stacks=1), | |
libqtile.layout.stack.Stack(num_stacks=2), | |
libqtile.layout.max.Max() | |
] | |
floating_layout = libqtile.layout.floating.Floating( | |
float_rules=[dict(wmclass="xclock")]) | |
keys = [ | |
libqtile.config.Key( | |
["control"], | |
"k", | |
libqtile.command._Call([("layout", None)], "up") | |
), | |
libqtile.config.Key( | |
["control"], | |
"j", | |
libqtile.command._Call([("layout", None)], "down") | |
), | |
] | |
mouse = [] | |
screens = [libqtile.config.Screen( | |
bottom=libqtile.bar.Bar( | |
[ | |
libqtile.widget.GroupBox(), | |
], | |
20 | |
), | |
)] | |
main = None | |
follow_mouse_focus = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Updating apt cache" | |
sudo apt-get update > /dev/null | |
echo "Adding dead-snakes" | |
sudo apt-get install -qq python-software-properties > /dev/null | |
sudo add-apt-repository ppa:fkrull/deadsnakes > /dev/null | |
echo "Re-updating apt cache" | |
sudo apt-get update > /dev/null | |
echo "Installing necessary packages" | |
sudo apt-get install -qq git xserver-xephyr x11-apps x11-xserver-utils xvfb libcairo2 pango1.0 > /dev/null | |
echo "Installing extra stuff for xcffib...." | |
sudo apt-get install -qq build-essential libffi-dev libxcb1-dev libxcb-render0-dev libgdk-pixbuf2.0-0 shared-mime-info > /dev/null | |
echo "Installing python 3.3" | |
sudo apt-get install -qq python3.3 python3.3-dev > /dev/null | |
sudo ln -sfv python3.3 /usr/bin/python > /dev/null | |
wget --quiet http://python-distribute.org/distribute_setup.py > /dev/null | |
sudo python -m distribute_setup install &> /dev/null | |
sudo easy_install pip > /dev/null | |
echo "Building xcb-proto" | |
wget --quiet http://xcb.freedesktop.org/dist/xcb-proto-1.10.tar.bz2 | |
tar xjf xcb-proto-1.10.tar.bz2 > /dev/null | |
pushd xcb-proto-1.10 > /dev/null | |
./configure --prefix=/usr > /dev/null | |
make -j3 > /dev/null | |
sudo make install > /dev/null | |
popd > /dev/null | |
echo "Fetching qtile from git" | |
git clone -b cffi-new-event-loop git://github.com/flacjacket/qtile.git > /dev/null | |
pushd qtile > /dev/null | |
echo "Installing Python dependencies" | |
sudo pip install -r requirements.txt > /dev/null | |
sudo pip install asyncio > /dev/null | |
echo "Installing qtile" | |
sudo pip install . > /dev/null | |
popd > /dev/null | |
echo "Installing Python test dependencies" | |
sudo pip install nose > /dev/null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#python -m pdb /usr/local/bin/qtile -l INFO -c /vagrant/config.py | |
python /usr/local/bin/qtile -l INFO -c /vagrant/config.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import libqtile.command | |
import os | |
import subprocess | |
import sys | |
import time | |
DISPLAY = ":98" | |
client = libqtile.command.Client() | |
# Info for window.py | |
python = sys.executable | |
d = os.path.dirname(os.path.realpath(__file__)) | |
path = os.path.join(d, "window.py") | |
args = [python, path, DISPLAY, "one"] | |
# Spawn window.py | |
start = len(client.windows()) | |
proc = subprocess.Popen(args, env={"DISPLAY": DISPLAY}) | |
for _ in range(50): | |
try: | |
if len(client.windows()) > start: | |
break | |
except RuntimeError: | |
pass | |
time.sleep(0.1) | |
else: | |
raise AssertionError | |
# RESIZE | |
subprocess.call( | |
[ | |
"xrandr", "-s", "480x640", | |
"-display", DISPLAY | |
] | |
) | |
# Should break? | |
for _ in range(10): | |
time.sleep(0.1) | |
d = client.screen.info() | |
if d["width"] == 480 and d["height"] == 640: | |
break | |
else: | |
raise AssertionError | |
proc.terminate() | |
proc.wait() | |
# un-resize | |
subprocess.call( | |
[ | |
"xrandr", "-s", "1280x1024", | |
"-display", DISPLAY | |
] | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "hashicorp/precise64" | |
# Install all the necessary things | |
config.vm.provision :shell do |sh| | |
sh.privileged = false | |
sh.path = "qtile-setup.sh" | |
end | |
# Setup xephyr on xvfb to run on display :98 | |
config.vm.provision :shell, run: "always" do |sh| | |
sh.privileged = false | |
sh.path = "xephyr.sh" | |
end | |
# A bit of a nasty hack to get rid of annoying errors | |
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" | |
# language-python needs more ram to compile | |
config.vm.provider "virtualbox" do |v| | |
v.memory = 1024 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "hashicorp/precise64" | |
# Install all the necessary things | |
config.vm.provision :shell do |sh| | |
sh.privileged = false | |
sh.path = "cairocffi-setup.sh" | |
end | |
# Setup xvfb to run on display :99 | |
config.vm.provision :shell, run: "always" do |sh| | |
sh.privileged = false | |
sh.path = "xvfb.sh" | |
end | |
# Install xcffib, either from pypi or from source | |
config.vm.provision :shell do |sh| | |
sh.privileged = false | |
# un-comment this to get xcffib from pypi | |
#sh.path = "xcffib-pip.sh" | |
# un-comment this to build xcffib from source | |
sh.path = "xcffib-source.sh" | |
end | |
# A bit of a nasty hack to get rid of annoying errors | |
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" | |
# language-python needs more ram to compile | |
config.vm.provider "virtualbox" do |v| | |
v.memory = 1024 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
This program is carefully crafted to exercise a number of corner-cases in | |
Qtile. | |
""" | |
from __future__ import print_function | |
import sys | |
import time | |
import xcffib | |
import xcffib.xproto | |
def configure(window): | |
window.configure( | |
width=100, | |
height=100, | |
x=0, | |
y=0, | |
border_width=1, | |
) | |
for i in range(20): | |
try: | |
conn = xcffib.connect(display=sys.argv[1]) | |
except xcffib.ConnectionException: | |
time.sleep(0.1) | |
continue | |
except Exception as v: | |
print("Error opening test window: ", type(v), v, file=sys.stderr) | |
sys.exit(1) | |
break | |
else: | |
print("Could not open window on display %s" % (sys.argv[1]), file=sys.stderr) | |
sys.exit(1) | |
screen = conn.get_setup().roots[conn.pref_screen] | |
window = conn.generate_id() | |
background = conn.core.AllocColor(screen.default_colormap, 0x2828, 0x8383, 0xCECE).reply().pixel # Color "#2883ce" | |
conn.core.CreateWindow(xcffib.CopyFromParent, window, screen.root, | |
100, 100, 100, 100, 1, | |
xcffib.xproto.WindowClass.InputOutput, screen.root_visual, | |
xcffib.xproto.CW.BackPixel | xcffib.xproto.CW.EventMask, | |
[background, xcffib.xproto.EventMask.StructureNotify | xcffib.xproto.EventMask.Exposure]) | |
conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace, | |
window, xcffib.xproto.Atom.WM_NAME, | |
xcffib.xproto.Atom.STRING, 8, len(sys.argv[2]), | |
sys.argv[2]) | |
wm_protocols = "WM_PROTOCOLS" | |
wm_protocols = conn.core.InternAtom(0, len(wm_protocols), wm_protocols).reply().atom | |
wm_delete_window = "WM_DELETE_WINDOW" | |
wm_delete_window = conn.core.InternAtom(0, len(wm_delete_window), wm_delete_window).reply().atom | |
conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace, | |
window, wm_protocols, | |
xcffib.xproto.Atom.ATOM, 32, 1, | |
[wm_delete_window]) | |
conn.core.ConfigureWindow(window, | |
xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y | | |
xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height | | |
xcffib.xproto.ConfigWindow.BorderWidth, | |
[0, 0, 100, 100, 1]) | |
conn.core.MapWindow(window) | |
conn.flush() | |
conn.core.ConfigureWindow(window, | |
xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y | | |
xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height | | |
xcffib.xproto.ConfigWindow.BorderWidth, | |
[0, 0, 100, 100, 1]) | |
try: | |
while 1: | |
event = conn.wait_for_event() | |
if event.__class__ == xcffib.xproto.ClientMessageEvent: | |
if conn.core.GetAtomName(event.data.data32[0]).reply().name.to_string() == "WM_DELETE_WINDOW": | |
sys.exit(1) | |
except xcffib.XcffibException: | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Installing xcffib from PyPi" | |
sudo pip install xcffib > /dev/null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Installing xcffib build dependencies" | |
sudo apt-get install -qq xcb-proto cabal-install happy alex parallel pkg-config > /dev/null 2>&1 | |
echo "Updating cabal" | |
cabal update > /dev/null | |
if [ -d xcffib ]; then | |
echo "xcfffib already checkedout" | |
else | |
echo "Checking out xcffib" | |
git clone git://github.com/tych0/xcffib.git > /dev/null | |
fi | |
pushd xcffib > /dev/null | |
echo "Building xcffib haskell dependencies (this will take a while...)" | |
cabal install --only-dependencies > /dev/null 2>&1 | |
cabal configure > /dev/null | |
echo "Installing Python build dependencies" | |
sudo pip install autopep8 > /dev/null | |
echo "Generating xcffib module" | |
make xcffib > /dev/null | |
echo "Installing xcffib" | |
sudo pip install . > /dev/null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Bringing up xvfb" | |
sudo /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16 | |
export DISPLAY=:99.0 | |
echo "Bringing up Xephyr" | |
sudo /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xephyr_98.pid --make-pidfile --background --exec /usr/bin/Xephyr -- :98 -ac -screen 1280x1024 +xinerama +extension RANDR | |
echo "export DISPLAY=:98.0" | sudo tee -a /etc/profile.d/xephyr.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Bringing up xvfb" | |
sudo /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16 | |
echo "export DISPLAY=:99.0" | sudo tee -a /etc/profile.d/xvfb.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment