Skip to content

Instantly share code, notes, and snippets.

@whitelynx
Created September 25, 2016 10:39
Show Gist options
  • Save whitelynx/3ed45f6da3055c01763151e5c2f45815 to your computer and use it in GitHub Desktop.
Save whitelynx/3ed45f6da3055c01763151e5c2f45815 to your computer and use it in GitHub Desktop.
i3 config
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
set $mixer_control Master
# Bar on top:
set $bar_pos top
set $dmenu_opts -i
#set $dmenu_opts -i -fn lime -nb black -nf white -sb '#225588' -sf white
# Bar on bottom:
#set $bar_pos bottom
#set $dmenu_opts -i -b
##set $dmenu_opts -i -fn lime -b -nb black -nf white -sb '#225588' -sf white
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
#font pango:monospace 8
font pango:lime 8
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8
# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesn’t scale on retina/hidpi displays.
# Hide vertical borders at the edge of the screen
hide_edge_borders both
# Use Mouse+$mod to drag floating windows to the desired position
floating_modifier $mod
# New container tiling mode
#workspace_layout stacking
workspace_layout tabbed
# Don't steal focus
focus_on_window_activation urgent
# Wrap focus around within containers
force_focus_wrapping yes
# Start a terminal
bindsym $mod+Return exec i3-sensible-terminal
# Kill focused window
bindsym $mod+Shift+C kill
# Start dmenu (a program launcher)
#bindsym $mod+e exec dmenu_run
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
bindsym $mod+p exec --no-startup-id j4-dmenu-desktop --dmenu="dmenu -p 'Start:' $dmenu_opts"
bindsym $mod+Shift+P exec --no-startup-id dmenu_run -p 'Run:' $dmenu_opts
# Change focus
bindsym $mod+h focus parent; focus left
bindsym $mod+t focus parent; focus down
bindsym $mod+n focus parent; focus up
bindsym $mod+s focus parent; focus right
bindsym $mod+o focus left
bindsym $mod+u focus right
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# Move focused window
bindsym $mod+Shift+H move left
bindsym $mod+Shift+T move down
bindsym $mod+Shift+N move up
bindsym $mod+Shift+S move right
bindsym $mod+Shift+o move left
bindsym $mod+Shift+u move right
# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# Enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# Change container layout (stacked, tabbed, toggle split)
bindsym $mod+apostrophe layout stacking
bindsym $mod+comma layout tabbed
bindsym $mod+period layout toggle split
# Toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# Change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# Toggle the scratchpad
bindsym $mod+grave scratchpad show
# Focus the parent container (PgDn)
bindsym $mod+Next focus parent
# Focus the child container (PgUp)
bindsym $mod+Prior focus child
# 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
# Reload the configuration file
bindsym $mod+Shift+R reload
# Restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Ctrl+r restart
# Exit i3 (logs you out of your X session)
bindsym $mod+Shift+Q exec --no-startup-id "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'"
bindsym $mod+Ctrl+q exec --no-startup-id i3-end-session-menu $dmenu_opts
# Resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the window’s width.
# Pressing right will grow the window’s width.
# Pressing up will shrink the window’s height.
# Pressing down will grow the window’s height.
bindsym h resize shrink width 10 px or 10 ppt
bindsym t resize grow height 10 px or 10 ppt
bindsym n resize shrink height 10 px or 10 ppt
bindsym s resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"
# Volume controls
bindsym XF86AudioRaiseVolume exec "amixer sset $mixer_control 1%+"
bindsym XF86AudioLowerVolume exec "amixer sset $mixer_control 1%-"
bindsym XF86AudioMute exec "amixer sset $mixer_control toggle"
# Other special keys
bindsym XF86Sleep exec "sudo systemctl hybrid-sleep"
# Start i3bar to display a workspace bar (plus the system information i3status finds out, if available)
#bar {
# status_command i3status
# tray_output primary
#}
bar {
status_command python ~/.config/i3pystatus/config.py
position $bar_pos
workspace_buttons yes
}
from i3pystatus import Status
status = Status(standalone=True)
# Displays clock like this:
# Tue 2014-07-30 23:59:46 -6:00
status.register("clock",
color="#888888",
#format="%a %-d %b %X KW%V",
format='%a %Y-%m-%d <span color="#0099ff">%H:%M:%S</span> %z',
hints={"markup": "pango"})
status.register("moon",
#format="{status}",
format='<span font="MoonPhase 8">{status}</span>',
status={
# Technically, these symbols are matched up in reverse (e.g., the "full moon" symbol is used for "New Moon")
# because this is going to be drawn in a light color on a black background, instead of black on white.
'New Moon': 'πŸŒ•',
'Waxing Crescent': 'πŸŒ–',
'First Quarter': 'πŸŒ—',
'Waxing Gibbous': '🌘',
'Full Moon': 'πŸŒ‘',
'Waning Gibbous': 'πŸŒ’',
'Last Quarter': 'πŸŒ“',
'Waning Crescent': 'πŸŒ”'
},
#hints={"separator": False})
hints={"separator": False, "markup": "pango"})
# Shows the average load of the last minute and the last 5 minutes
# (the default value for format is used)
#status.register("load")
# Graph CPU usage
status.register("cpu_usage_graph",
graph_style='blocks',
#graph_style='braille-peak',
#graph_style='braille-snake',
#graph_style='braille-fill',
graph_width=60,
interval=0.5,
#format='<span font="Braille 10" font_stretch="ultracondensed" letter_spacing="-1024">{cpu_graph}</span>',
#format='<span font="creep 14">{cpu_graph}</span>',
format='<span font="VerticalBar 8">{cpu_graph}</span>',
hints={"markup": "pango"})
# Shows your CPU temperature, if you have a Intel CPU
status.register("temp",
format="🌑 {temp:.1f}°C")
# GPU temp
#status.register("gpu_temp")
# This would look like this when discharging:
# πŸ”‹β¬‡ 77.81% [56.15%] 2h:41m
# Like this when charging:
# πŸ”‹βš‘πŸ”Œ 92.24% [74.33%] 22m
# And like this if full:
# πŸ”‹π€ 100.0% [91.21%]
#
# This would also display a desktop notification (via D-Bus) if the percentage
# goes below 5 percent while discharging. The block will also color RED.
# If you don't have a desktop notification daemon yet, take a look at dunst:
# http://www.knopwob.org/dunst/
status.register("battery",
format="{status} {percentage:.1f}% ({percentage_design:.1f}%) {remaining}",
status={
"DPL": "πŸ”‹βƒ ", # "Depleted", since the abbreviation isn't directly obvious.
"DIS": "πŸ”‹β¬‡",
"CHR": "πŸ”‹βš‘πŸ”Œ",
"FULL": "πŸ”‹π€",
},
alert=True,
alert_percentage=13,
critical_level_percentage=7,
critical_level_command="sudo systemctl hybrid-sleep")
# Displays internet connection status
#status.register("online")
# Shows the address and up/down state of eth0. If it is up the address is shown in
# green (the default value of color_up) and the CIDR-address is shown
# (i.e. 10.10.10.42/24).
# If it's down just the interface name (eth0) will be displayed in red
# (defaults of format_down and color_down)
#
# Note: the network module requires PyPI package netifaces
status.register("network",
interface="enp2s0",
format_up="πŸ–§ {v4}",
format_down="πŸ–§")
# Note: requires both netifaces and basiciw (for essid and quality)
status.register("network",
interface="wlp3s0",
format_up="πŸ“Ά {essid} {quality:.1f}% {v4}",
format_down="πŸ“Ά")
# Shows disk usage of /
# Format:
# 42/128G [86G]
status.register("disk",
path="/",
format="{used}/{total}G [{avail}G]")
# Show the current state of the keyboard locks
status.register("keyboard_locks",
caps_on='<span bgcolor="yellow" color="black">CAPS</span>',
caps_off='',
num_on='<span bgcolor="green" color="black">NUM</span>',
num_off='',
scroll_on='<span bgcolor="blue" color="black">SCR</span>',
scroll_off='',
color="#888888",
hints={"markup": "pango"})
# Shows pulseaudio default sink volume
#
# Note: requires libpulseaudio from PyPI
#status.register("pulseaudio",
# format="β™ͺ{volume}")
# Shows alsa default mixer volume
#
# Note: requires pyalsaaudio from PyPI
status.register("alsa",
format="πŸ”‰ {volume}%",
format_muted="πŸ”‡ MUTE")
# Shows mpd status
# Format:
# Cloud connectedβ–ΆReroute to Remain
#status.register("mpd",
# format="{title}{status}{album}",
# status={
# "pause": "β–·",
# "play": "β–Ά",
# "stop": "β—Ύ",
# })
status.run()
#!/bin/bash
declare -a dmenu_opts=("$@")
if [ "$#" -lt 1 ]; then
dmenu_opts=("-i")
fi
set -x
choice=$(dmenu -p "Action:" "${dmenu_opts[@]}" <<-EOF
Log Out
Suspend
Hibernate
Reboot
PowerOff
EOF
)
function loginManagerCommand() {
command="$1"
dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.$command" boolean:true
}
case "$choice" in
'Log Out') i3-msg exit ;;
Suspend) xdg-screensaver lock & loginManagerCommand Suspend ;;
Hibernate) xdg-screensaver lock & loginManagerCommand Hibernate ;;
Reboot) loginManagerCommand Reboot ;;
PowerOff) loginManagerCommand PowerOff ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment