1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

Added i3 config

This commit is contained in:
2016-03-31 03:06:44 +01:00
parent 0b3c202af2
commit a2e1130b2a
23 changed files with 1346 additions and 0 deletions

19
.config/i3/alt-tab.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# ================================================================================== #
# Focus the next window on the current workspace in i3, e.g. for binding to Alt+Tab #
# Depends: jq, awk, i3wm (obviously) #
# Author: Nervengift <dev@nerven.gift> #
# License: Don't think this deserves a license, Public Domain #
# Known bugs: doesn't work with non-window container focused #
# ================================================================================== #
ws=$(i3-msg -t get_workspaces|jq "map(select(.focused))[]|.name")
echo $ws
windows=$(i3-msg -t get_tree|jq ".nodes|map(.nodes[])|map(.nodes[])|map(select(.type==\"workspace\" and .name==$ws))[0].nodes|map(recurse(.nodes[]))|map(.window)|.[]|values")
echo $windows
current=$(i3-msg -t get_tree|jq "recurse(.nodes[])|select(.focused)|.window")
echo $current
if [ "x$current" != "xnull" ]; then
next=$(echo $windows | awk "BEGIN {RS=\" \";FS=\" \"};NR == 1 {w=\$1};{if (f == 1){w=\$1;f=0}else if (\$1 == \"$current\") f=1};END {print w}")
i3-msg [id=$next] focus > /dev/null
fi

154
.config/i3/config Normal file
View File

@ -0,0 +1,154 @@
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
floating_modifier $mod
font pango:Noto Sans 11
# kill focused window
bindsym $mod+apostrophe kill
bindsym Mod1+F4 kill
# move focused window
bindsym $mod+Left move left
bindsym $mod+Down move down
bindsym $mod+Up move up
bindsym $mod+Right move right
# split in horizontal orientation
bindsym $mod+h split h
bindsym $mod+t split v
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+o layout stacking
bindsym $mod+comma layout tabbed
bindsym $mod+period layout toggle split
# toggle tiling / floating
bindsym $mod+u floating toggle
# focus the parent container
bindsym $mod+a focus parent
bindsym $mod+d focus child
# Screen configs #
set $left "DP-1.1"
set $centre "DP-1.2.1"
set $right "DP-1.2.2"
set $top "HDMI-0"
# Workspace -> Screen
workspace 1 output $left
workspace 2 output $centre
workspace 3 output $right
workspace 4 output $top
# switch to workspace
bindsym $mod+1 workspace 1
bindsym $mod+2 workspace 2
bindsym $mod+3 workspace 3
bindsym $mod+4 workspace 4
bindsym $mod+5 workspace 5
bindsym $mod+6 workspace 6
bindsym $mod+7 workspace 7
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9
bindsym $mod+0 workspace 10
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace 1
bindsym $mod+Shift+2 move container to workspace 2
bindsym $mod+Shift+3 move container to workspace 3
bindsym $mod+Shift+4 move container to workspace 4
bindsym $mod+Shift+5 move container to workspace 5
bindsym $mod+Shift+6 move container to workspace 6
bindsym $mod+Shift+7 move container to workspace 7
bindsym $mod+Shift+8 move container to workspace 8
bindsym $mod+Shift+9 move container to workspace 9
bindsym $mod+Shift+0 move container to workspace 10
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+Escape exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
set $bg-color #2f343f
set $inactive-bg-color #2f343f
set $text-color #f3f4f5
set $inactive-text-color #676E7D
set $urgent-bg-color #E53935
# window colors
# border background text indicator
client.focused $bg-color $bg-color $text-color #00ff00
client.unfocused $inactive-bg-color $inactive-bg-color $inactive-text-color #00ff00
client.focused_inactive $inactive-bg-color $inactive-bg-color $inactive-text-color #00ff00
client.urgent $urgent-bg-color $urgent-bg-color $text-color #00ff00
bar {
status_command i3blocks -c ~/.config/i3blocks/config
workspace_buttons yes
strip_workspace_numbers yes
tray_output primary
tray_padding 0
height 24
output $centre
position top
colors {
separator #757575
background #2f343f
# border background text
focused_workspace $bg-color $bg-color $text-color
inactive_workspace $inactive-bg-color $inactive-bg-color $inactive-text-color
urgent_workspace $urgent-bg-color $urgent-bg-color $text-color
}
}
# remove window border, add spacing
for_window [class="^.*"] border pixel 0
gaps inner 10
gaps outer 2
#smart_gaps on
# Do not follow the mouse
focus_follows_mouse no
# keybindings
bindsym $mod+Shift+j reload
bindsym $mod+Shift+p restart
bindsym Mod1+Tab exec ~/.config/i3/alt-tab.sh
bindsym $mod+Return exec i3-sensible-terminal
bindsym $mod+l exec ~/.config/i3/lock.sh
bindsym $mod+space exec rofi -show run -fg "#D3DAE3" -bg "#383C4A" -hlbg "#5294E2"
bindsym Print exec sh imgur-screenshot -s
bindsym $mod+Print exec sh imgur-screenshot
bindsym $mod+Shift+Return exec --no-startup-id ~/.config/i3/cycleaudio.py && pkill -RTMIN+10 i3blocks
# Media player controls
bindsym XF86AudioPlay exec --no-startup-id mpc toggle
bindsym XF86AudioPause exec --no-startup-id mpc pause
bindsym XF86AudioStop exec --no-startup-id mpc stop
bindsym XF86AudioNext exec --no-startup-id mpc next
bindsym XF86AudioPrev exec --no-startup-id mpc previous
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% && pkill -RTMIN+10 i3blocks
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% && pkill -RTMIN+10 i3blocks
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && pkill -RTMIN+10 i3blocks
# app launch shortcuts
exec_alawys --no-startup-id ~/.fehbg
exec_always --no-startup-id ~/.config/i3/disable-standby-fs.py
exec xautolock -time 10 -locker /usr/bin/lock.sh
bindsym $mod+c exec --no-startup-id google-chrome-stable
exec dex -a
exec redshift
exec compton -b --config ~/.config/compton.conf
exec i3-msg 'workspace 2; exec i3-sensible-terminal'
exec --no-startup-id i3-msg 'workspace 3; exec google-chrome-stable'

31
.config/i3/cycleaudio.py Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env python3
import subprocess as sp
import re
# This script cycles pulseaudio sinks and changes the defaults.
# Audio playback is also moved to the new default sink. The script
# is intended to bind to some keyboard shortcut to cycle through
# outputs on the fly.
#
# Requirements: pacmd, python3
dev_out, _ = sp.Popen('pacmd list-sinks', shell=True, stdout=sp.PIPE).communicate()
inp_out, _ = sp.Popen('pacmd list-sink-inputs', shell=True, stdout=sp.PIPE).communicate()
devices = re.findall(r"(\*?) index: (\d+)", str(dev_out))
inputs = re.findall(r"index: (\d+)", str(inp_out))
# find the next default device, i.e., the one after the current default
found = False
next_device = devices[0][1]
for d in devices:
if found:
next_device = d[1]
break
found = (d[0] == "*")
# set default device and move inputs
sp.call(["pacmd", "set-default-sink", next_device])
for i in inputs:
sp.call(["pacmd", "move-sink-input", i, next_device])

View File

@ -0,0 +1,33 @@
#!/usr/bin/env python3
from argparse import ArgumentParser
from subprocess import call
import i3ipc
i3 = i3ipc.Connection()
parser = ArgumentParser(prog='disable-standby-fs',
description='''
Disable standby (dpms) and screensaver when a window becomes fullscreen
or exits fullscreen-mode. Requires `xorg-xset`.
''')
args = parser.parse_args()
def on_fullscreen_mode(i3, e):
if e.container.props.fullscreen_mode:
call(['xset', 's', 'off'])
call(['xset', '-dpms'])
else:
call(['xset', 's', 'on'])
call(['xset', '+dpms'])
def on_window_close(i3, e):
if e.container.props.fullscreen_mode:
call(['xset', 's', 'on'])
call(['xset', '+dpms'])
i3.on('window::fullscreen_mode', on_fullscreen_mode)
i3.on('window::close', on_window_close)
i3.main()

1
.config/i3/i3 Symbolic link
View File

@ -0,0 +1 @@
i3

BIN
.config/i3/lock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

41
.config/i3/lock.sh Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
icon="$HOME/.config/i3/lock.png"
tmpbg='/tmp/screen.png'
(( $# )) && { icon=$1; }
# screenshot
scrot "$tmpbg"
PX=0
PY=0
# lockscreen image info
R=$(file $icon | grep -o '[0-9]* x [0-9]*')
RX=$(echo $R | cut -d' ' -f 1)
RY=$(echo $R | cut -d' ' -f 3)
RES=$(xrandr --query | grep ' connected primary' | cut -f4 -d' ')
# monitor position/offset
SRX=$(echo $RES | cut -d'x' -f 1) # x pos
SRY=$(echo $RES | cut -d'x' -f 2 | cut -d'+' -f 1) # y pos
SROX=$(echo $RES | cut -d'x' -f 2 | cut -d'+' -f 2) # x offset
SROY=$(echo $RES | cut -d'x' -f 2 | cut -d'+' -f 3) # y offset
PX=$(($SROX + $SRX/2 - $RX/2))
PY=$(($SROY + $SRY/2 - $RY/2))
# pixelize and add lock icon
convert $tmpbg -scale 5% -scale 2000% $tmpbg
convert $tmpbg $icon -geometry +$PX+$PY -composite -matte $tmpbg
playing=$(mpc status | grep playing | wc -l)
[[ $playing == 1 ]] && mpc pause
i3lock -i "$tmpbg" -n -e
[[ $playing == 1 ]] && mpc play
rm "$tmpbg"