mirror of
https://github.com/balkian/dotfiles.git
synced 2025-08-23 16:02:19 +00:00
Several improvements.
* Tmux is not started by default anymore * Added functions for i3 - Awesome!! * zsh to start tmux
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/bin/zsh
|
||||
python2 $HOME/.bin/i3-wm-scripts/nextmatch.py urxvt
|
||||
python2 $HOME/.bin/i3-wm-scripts/nextmatch.py tmux
|
||||
if [ $? -gt 0 ]; then
|
||||
urxvt & sleep 0.1 && python2 $HOME/.bin/i3-wm-scripts/nextmatch.py urxvt
|
||||
urxvt -e tmux attach & sleep 0.1 && python2 $HOME/.bin/i3-wm-scripts/nextmatch.py tmux
|
||||
fi
|
||||
if [ "$#" -gt 0 ]; then
|
||||
eval "tmux neww"
|
||||
|
61
bin/i3-winmenu.py
Executable file
61
bin/i3-winmenu.py
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python
|
||||
# dmenu script to jump to windows in i3.
|
||||
#
|
||||
# using ziberna's i3-py library: https://github.com/ziberna/i3-py
|
||||
# depends: dmenu (vertical patch), i3.
|
||||
# released by joepd under WTFPLv2-license:
|
||||
# http://sam.zoy.org/wtfpl/COPYING
|
||||
#
|
||||
# edited by Jure Ziberna for i3-py's examples section
|
||||
|
||||
import i3
|
||||
import subprocess
|
||||
|
||||
|
||||
def i3clients():
|
||||
"""
|
||||
Returns a dictionary of key-value pairs of a window text and window id.
|
||||
Each window text is of format "[workspace] window title (instance number)"
|
||||
"""
|
||||
clients = {}
|
||||
for ws_num in range(1, 11):
|
||||
workspace = i3.filter(num=ws_num)
|
||||
if not workspace:
|
||||
continue
|
||||
workspace = workspace[0]
|
||||
windows = i3.filter(workspace, nodes=[])
|
||||
instances = {}
|
||||
# Adds windows and their ids to the clients dictionary
|
||||
for window in windows:
|
||||
win_str = '[%s] %s' % (workspace['name'], window['name'])
|
||||
# Appends an instance number if other instances are present
|
||||
if win_str in instances:
|
||||
instances[win_str] += 1
|
||||
win_str = '%s (%d)' % (win_str, instances[win_str])
|
||||
else:
|
||||
instances[win_str] = 1
|
||||
clients[win_str] = window['id']
|
||||
return clients
|
||||
|
||||
|
||||
def win_menu(clients, l=10):
|
||||
"""
|
||||
Displays a window menu using dmenu. Returns window id.
|
||||
"""
|
||||
dmenu = subprocess.Popen(['/usr/bin/dmenu', '-i', '-l', str(l),
|
||||
'-fn', '"-*-cure-medium-*-*-*-11-*-*-*-*-*-*-*"',
|
||||
'-nb', '#101010', '-nf', '#5f5f5f', '-sb', '#191919',
|
||||
'-sf', '#b72f62'],
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE)
|
||||
menu_str = '\n'.join(sorted(clients.keys()))
|
||||
# Popen.communicate returns a tuple stdout, stderr
|
||||
win_str = dmenu.communicate(menu_str.encode('utf-8'))[0].decode('utf-8')\
|
||||
.rstrip()
|
||||
return clients.get(win_str, None)
|
||||
|
||||
if __name__ == '__main__':
|
||||
clients = i3clients()
|
||||
win_id = win_menu(clients)
|
||||
if win_id:
|
||||
i3.focus(con_id=win_id)
|
Reference in New Issue
Block a user