diff options
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | bin/status | 86 | ||||
-rw-r--r-- | i3/config | 115 | ||||
-rw-r--r-- | i3status.conf | 33 | ||||
-rw-r--r-- | xinitrc | 4 |
5 files changed, 239 insertions, 1 deletions
@@ -12,6 +12,7 @@ INSTALL = abcde.conf \ gitignore \ gtkrc \ gtkrc-2.0 \ + i3status.conf \ inputrc \ logout \ minicpanrc \ @@ -34,6 +35,7 @@ INSTALL = abcde.conf \ sh \ bin \ dzil \ + i3 \ interhack \ irssi \ fortune \ diff --git a/bin/status b/bin/status new file mode 100755 index 0000000..8b39c93 --- /dev/null +++ b/bin/status @@ -0,0 +1,86 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.010; + +use JSON; + +open my $i3status, '-|', 'i3status'; + +print scalar(<$i3status>); +print scalar(<$i3status>); + +while (<$i3status>) { + my $comma = s/^,//; + my $line = decode_json($_); + for my $item (@$line) { + next unless $item->{name} eq 'wireless' || $item->{name} eq 'ethernet'; + my $iface = $item->{instance}; + my ($up, $down) = map { human_bytes(net_rate($iface, $_)) } 'rx', 'tx'; + $item->{full_text} =~ s{^($iface:)}{sprintf("%s %6s/%6s", $1, $up, $down)}e; + } + unshift @$line, { name => 'title', full_text => get_title() }; + say(($comma ? ',' : ''), encode_json($line)); +} + +print <$i3status>; + +sub get_title { + my $node = find(decode_json(`i3-msg -t get_tree`)); + if ($node->{window}) { + return $node->{name}; + } + else { + return '-none-'; + } +} + +sub find { + my ($t) = @_; + if ($t->{focused}) { + return $t; + } + + for my $subtree (@{ $t->{nodes} }) { + my $found = find($subtree); + return $found if $found; + } + + return; +} + +{ + my %last_bytes; + sub net_rate { + my ($iface, $which) = @_; + my $stat_file = "/sys/class/net/$iface/statistics/${which}_bytes"; + chomp(my $bytes = slurp($stat_file)); + my $prev = $last_bytes{$iface}{$which}; + $last_bytes{$iface}{$which} = $bytes; + return 0 unless defined $prev; + return $bytes - $prev; + } +} + +sub human_bytes { + my ($bytes) = @_; + my @prefixes = ('', qw(k M G T)); + my $prefix_index = 0; + while ($bytes > 512) { + $bytes /= 1024; + $prefix_index++; + } + my $prec = ($prefix_index == 0 ? 0 : 1); + return sprintf("%0.${prec}f%sB", $bytes, $prefixes[$prefix_index]); +} + +sub slurp { + open my $fh, '<', $_[0] or die "Couldn't open $_[0]: $!"; + if (wantarray) { + <$fh> + } + else { + local $/; + <$fh> + } +} diff --git a/i3/config b/i3/config new file mode 100644 index 0000000..1e8616c --- /dev/null +++ b/i3/config @@ -0,0 +1,115 @@ +# i3 config file (v4) +# +# Please see http://i3wm.org/docs/userguide.html for a complete reference! + +set $mod Mod1+Ctrl +set $layout_mod Mod4 + +# Font for window titles. Will also be used by the bar unless a different font +# is used in the bar {} block below. +font 6x10 + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $layout_mod + +# window decorations +new_window 1pixel +client.focused #aaaaaa #aaaaaa #ffffff #ffffff +client.focused_inactive #000000 #000000 #ffffff #888888 +client.unfocused #000000 #000000 #ffffff #888888 +client.urgent #ff0000 #ff0000 #ffffff #ff0000 + +floating_minimum_size 1 x 1 +floating_maximum_size -1 x -1 + +# floats +for_window [class="Xmessage"] floating enable +for_window [class="qemu"] floating enable +for_window [class="Gimp"] floating enable +for_window [instance="pwsafe"] floating enable +for_window [instance="pwsafe"] move absolute position 0 px 0 px +for_window [instance="urxvt-kuake"] floating enable +for_window [instance="urxvt-kuake"] move absolute position 0 px 0 px +for_window [class="qemu-system-x86_64"] floating enable +for_window [class="plugin-container"] floating enable +for_window [instance="explorer.exe"] floating enable +for_window [instance="winecfg.exe"] floating enable +for_window [instance="winedbg.exe"] floating enable +for_window [window_role="CallWindow"] floating enable + +# special desktops +for_window [class="Xpdf"] move window to workspace 4 +for_window [class="feh"] move window to workspace 4 + +# start programs +bindsym $mod+o exec urxvtc +bindsym $mod+b exec firefox +bindsym $mod+i exec dmenu -p "pwsafe -p" < /dev/null | xargs -I{} urxvtc -name pwsafe -geometry 47x2 -e pwsafe -p {} +bindsym $mod+Shift+i exec dmenu -p "pwsafe -up" < /dev/null | xargs -I{} urxvtc -name pwsafe -geometry 47x2 -e pwsafe -up {} +bindsym $mod+r exec dmenu_run + +# XXX +# bindsym $mod+Shift+o exec urxvtc; exec urxvtc; exec sleep 1; split v; exec urxvtc; exec urxvtc; exec sleep 1; focus left; split v; exec urxvtc + +# kill focused window +bindsym $mod+q kill + +# window manipulation +bindsym $mod+h focus left +bindsym $mod+j focus down +bindsym $mod+k focus up +bindsym $mod+l focus right + +bindsym $mod+Shift+h move left +bindsym $mod+Shift+j move down +bindsym $mod+Shift+k move up +bindsym $mod+Shift+l move right + +bindsym $layout_mod+h split h +bindsym $layout_mod+v split v + +bindsym $layout_mod+f fullscreen + +bindsym $layout_mod+Shift+space floating toggle +bindsym $layout_mod+space focus mode_toggle + +# workspace manipulation +bindsym $mod+Left workspace prev +bindsym $mod+Right workspace next + +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+Shift+Left move window to workspace prev +bindsym $mod+Shift+Right move window to workspace next + +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 + +# reload the configuration file +bindsym $mod+c reload +# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) +bindsym $mod+Shift+c restart +# exit i3 (logs you out of your X session) +bindsym $mod+Shift+q 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'" + +# Start i3bar to display a workspace bar (plus the system information i3status +# finds out, if available) +bar { + tray_output primary + status_command ~/.bin/status +} diff --git a/i3status.conf b/i3status.conf new file mode 100644 index 0000000..603bc2c --- /dev/null +++ b/i3status.conf @@ -0,0 +1,33 @@ +general { + output_format = i3bar + interval = 1 +} + +order += "cpu_usage" +order += "wireless wlan0" +order += "ethernet eth0" +order += "battery 0" +order += "time" + +cpu_usage { + format = "CPU: %usage" +} + +wireless wlan0 { + format_up = "wlan0: (%essid: %quality)" + format_down = "wlan0" +} + +ethernet eth0 { + format_up = "eth0: (%speed)" + format_down = "eth0" +} + +battery 0 { + last_full_capacity = true + format = "%status %percentage (%remaining)" +} + +time { + format = "%a %b %d %H:%M:%S" +} @@ -10,4 +10,6 @@ pidof svscan || (svscan $HOME/.services 2>&1 | readproctitle $USER ............. setxkbmap -option compose:menu synclient HorizEdgeScroll=1 -exec xmonad +upower -e + +exec i3 |