From 7bbcb17419c60d30bb518764af534b786cf5f3a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 12 Jul 2013 19:19:52 +0200 Subject: [PATCH] Several improvements. * Tmux is not started by default anymore * Added functions for i3 - Awesome!! * zsh to start tmux --- Xresources | 2 +- bin/i3-one-tmux | 4 +-- bin/i3-winmenu.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++ i3/config | 61 +++++++++++++++++++++++++++++----------------- not_dots/clipboard | 9 +++++++ starttmux | 1 + tmux.conf | 9 +++---- vimrc | 2 +- zshrc | 2 +- 9 files changed, 117 insertions(+), 34 deletions(-) create mode 100755 bin/i3-winmenu.py create mode 100644 not_dots/clipboard diff --git a/Xresources b/Xresources index 6462d82..6d69ea8 100644 --- a/Xresources +++ b/Xresources @@ -42,7 +42,7 @@ URxvt.scrollBar: false ! Perl extensions URxvt.perl-ext-common: default,matcher URxvt.matcher.button: 1 -URxvt.urlLauncher: google-chrome +URxvt.url-launcher: google-chrome ! Cursor URxvt.cursorBlink: true diff --git a/bin/i3-one-tmux b/bin/i3-one-tmux index 1b3f9ce..48f8ed8 100755 --- a/bin/i3-one-tmux +++ b/bin/i3-one-tmux @@ -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" diff --git a/bin/i3-winmenu.py b/bin/i3-winmenu.py new file mode 100755 index 0000000..17dc0ec --- /dev/null +++ b/bin/i3-winmenu.py @@ -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) diff --git a/i3/config b/i3/config index 71e8570..9effd02 100644 --- a/i3/config +++ b/i3/config @@ -21,12 +21,14 @@ floating_modifier $mod #/exec # start a terminal bindsym $mod+Return exec i3-one-tmux +bindsym Control+Mod1+t exec urxvt # start lock -bindsym Control+Mod1+l exec i3lock +bindsym Control+Mod1+l exec i3lock -c 000000 -t -i ~/Pictures/Wallpapers/Game\ Over\ Hacker.png bindsym Control+Mod1+w exec i3-one-instance google-chrome bindsym Control+Mod1+g exec i3-one-instance gvim +bindsym $mod+o exec i3-winmenu.py bindsym Control+Mod1+f exec pcmanfm # Spotify @@ -34,6 +36,11 @@ bindsym XF86AudioPlay exec spotify-remote.py -a playPause bindsym XF86AudioNext exec spotify-remote.py -a next bindsym XF86AudioPrev exec spotify-remote.py -a previous +# Volume +bindsym XF86AudioRaiseVolume exec volume-up.sh +bindsym XF86AudioLowerVolume exec volume-down.sh +bindsym XF86AudioMute exec volume-toggle-mute.sh + # kill focused window bindsym $mod+q kill @@ -96,30 +103,30 @@ bindsym $mod+a focus parent bindsym $mod+d focus child # switch to workspace -bindsym $mod+1 workspace number 1 -bindsym $mod+2 workspace number 2 -bindsym $mod+3 workspace number 3 -bindsym $mod+4 workspace number 4 -bindsym $mod+5 workspace number 5 -bindsym $mod+6 workspace number 6 -bindsym $mod+7 workspace number 7 -bindsym $mod+8 workspace number 8 -bindsym $mod+9 workspace number 9 +bindsym $mod+1 workspace 1: Term +bindsym $mod+2 workspace 2: Web +bindsym $mod+3 workspace 3: Edit +bindsym $mod+4 workspace 4: Viewer +bindsym $mod+5 workspace 5: Files +bindsym $mod+6 workspace 6: Music +bindsym $mod+7 workspace 7: Chat +bindsym $mod+8 workspace 8: Misc Big +bindsym $mod+9 workspace 9: Misc Small bindsym $mod+0 workspace number 10 bindsym $mod+Control+h workspace prev bindsym $mod+Control+l workspace next # move focused container to workspace -bindsym $mod+Shift+exclam move container to workspace number 1 -bindsym $mod+Shift+at move container to workspace number 2 -bindsym $mod+Shift+numbersign move container to workspace number 3 -bindsym $mod+Shift+dollar move container to workspace number 4 -bindsym $mod+Shift+percent move container to workspace number 5 -bindsym $mod+Shift+asciicircum move container to workspace number 6 -bindsym $mod+Shift+ampersand move container to workspace number 7 -bindsym $mod+Shift+asterisk move container to workspace number 8 -bindsym $mod+Shift+parenleft move container to workspace number 9 -bindsym $mod+Shift+parenright move container to workspace number 10 +bindsym $mod+Shift+exclam move container to workspace 1: Term +bindsym $mod+Shift+at move container to workspace 2: Web +bindsym $mod+Shift+numbersign move container to workspace 3: Edit +bindsym $mod+Shift+dollar move container to workspace 4: Viewer +bindsym $mod+Shift+percent move container to workspace 5: Files +bindsym $mod+Shift+asciicircum move container to workspace 6: Music +bindsym $mod+Shift+ampersand move container to workspace 7: Chat +bindsym $mod+Shift+asterisk move container to workspace 8: Misc Big +bindsym $mod+Shift+parenleft move container to workspace 9: Misc Small +bindsym $mod+Shift+parenright move container to workspace number 10 # reload the configuration file bindsym $mod+Shift+C reload @@ -186,11 +193,13 @@ client.urgent #2f343a #101010 #93a1a1 #900000 for_window [class="^Google-chrome$"] border none assign [class="Google-chrome" window_role="browser"] 2: Web for_window [class="^URxvt$"] border 1px -assign [class="^URxvt$"] 1: Term +assign [title="^tmux$"] 1: Term assign [class="^Gvim$"] 3: Edit assign [class="^Evince$"] 4: Viewer assign [class="^Spotify$"] 6: Music assign [class="^Audacious$"] 6: Music +assign [class="^Audacious$"] 6: Music +assign [class="^Xchat$"] 7: Chat workspace "1: Term" output DP1 workspace "2: Web" output DP1 @@ -198,7 +207,13 @@ workspace "3: Edit" output DP1 workspace "4: Viewer" output eDP1 workspace "5: Files" output eDP1 workspace "6: Music" output eDP1 -workspace "7: Misc Big" output DP1 -workspace "8: Misc Small" output eDP1 +workspace "7: Chat" output eDP1 +workspace "8: Misc Big" output DP1 +workspace "9: Misc Small" output eDP1 exec --no-startup-id nm-applet +exec --no-startup-id dropbox start +exec --no-startup-id volti +exec --no-startup-id clipit +exec xautolock -time 10 -locker 'i3lock -t -c 000000 -i ~/Pictures/Wallpapers/Game\ Over\ Hacker.png' & +exec urxvt -e tmux attach diff --git a/not_dots/clipboard b/not_dots/clipboard new file mode 100644 index 0000000..f1eeb0f --- /dev/null +++ b/not_dots/clipboard @@ -0,0 +1,9 @@ +#! /usr/bin/perl +# /usr/lib/urxvt/perl/clipboard + +sub on_sel_grab { + my $query=quotemeta $_[0]->selection; + $query=~ s/\n/\\n/g; + $query=~ s/\r/\\r/g; + system( "echo " . $query . " | xsel -i -b -p" ); +} diff --git a/starttmux b/starttmux index 00d8063..021e3ce 100755 --- a/starttmux +++ b/starttmux @@ -1,3 +1,4 @@ +#!/bin/zsh # TMUX # if [[ -z "$KONSOLE_DBUS_SERVICE" & `which tmux` ]]; then # if no session is started, start a new session diff --git a/tmux.conf b/tmux.conf index 444886e..6eb0ed1 100644 --- a/tmux.conf +++ b/tmux.conf @@ -19,10 +19,6 @@ bind j select-pane -D bind k select-pane -U bind l select-pane -R - -bind-key -t vi-copy 'v' begin-selection -bind-key -t vi-copy 'y' copy-selection - # use vim motion keys while in copy mode setw -g mode-keys vi # use the vim resize keys. @@ -83,8 +79,9 @@ unbind [ bind Escape copy-mode unbind p bind p paste-buffer -bind-key -t vi-copy 'v' begin-selection -bind-key -t vi-copy 'y' copy-selection +bind-key -t vi-copy v begin-selection +bind-key -t vi-copy y copy-selection +bind-key -t vi-copy C-v rectangle-toggle unbind C-s # copy tmux buffer to clipboard #bind-key Y save-buffer ~/.tmux/buffer \; run-shell "xsel -i -p <~/.tmux/buffer && rm ~/.tmux/buffer" diff --git a/vimrc b/vimrc index b142eda..df1ca7e 100644 --- a/vimrc +++ b/vimrc @@ -76,7 +76,7 @@ noremap \ , " noremap ,cc :silent s/^/=escape(b:comment_leader,'\/')/:nohlsearch " noremap ,cu :silent s/^\V=escape(b:comment_leader,'\/')//e:nohlsearch " -imap "+gp +imap "+gP noremap :w imap :w diff --git a/zshrc b/zshrc index 9103a82..a9059fe 100644 --- a/zshrc +++ b/zshrc @@ -2,7 +2,7 @@ export PATH="$PATH:$HOME/.bin/" # Only update the path if not running interactively [ -z "$PS1" ] && return - source ~/.starttmux +#source ~/.starttmux # Path to your oh-my-zsh configuration. ZSH=$HOME/.oh-my-zsh