From ea2954b21e3be8a78f4682f2a2abc9da27040500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Sun, 3 Dec 2017 15:34:15 +0100 Subject: [PATCH] Add rotation script and default shell in tmux --- scripts/.bin/rotate.py | 28 ++++++++++++++++++++++++++++ tmux/.tmux.conf | 1 + 2 files changed, 29 insertions(+) create mode 100755 scripts/.bin/rotate.py diff --git a/scripts/.bin/rotate.py b/scripts/.bin/rotate.py new file mode 100755 index 0000000..ac61be9 --- /dev/null +++ b/scripts/.bin/rotate.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +import subprocess +import sys + + +def rotate(screen="", rotate="inverted"): + matchline = [ + l.split() for l in subprocess.check_output(["xrandr"]).decode("utf-8").splitlines()\ + if screen in l and ' connected' in l + ] + for line in matchline: + s = line[ + line.index([s for s in line if s.count("+") == 2][0])+1 + ] + + r = "normal" if s == rotate else rotate + screen = line[0] + subprocess.call(["xrandr", "--output", screen, "--rotate", r]) + + +if __name__ == '__main__': + screen = '' + rotation = 'inverted' + if len(sys.argv) > 1: + screen = sys.argv[1] + if len(sys.argv) > 2: + rotation = sys.argv[2] + rotate(screen, rotation) diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf index d9bcc9f..1a554bc 100644 --- a/tmux/.tmux.conf +++ b/tmux/.tmux.conf @@ -86,6 +86,7 @@ unbind C-s # Look better # look good set -g default-terminal "screen-256color" +set-option -g default-shell ${SHELL} # Maximise and minimise panes. TMUX NOW COMES WITH ZOOM: C-a z