From 7a99937b12abbceadbdb227f9f661efb09fbe5b2 Mon Sep 17 00:00:00 2001 From: aszlig Date: Fri, 2 May 2014 01:21:35 +0200 Subject: Move i3 configuration into its own module. We want to keep common.nix nice and clean and in the long term the whole config should be more modular. Signed-off-by: aszlig --- cfgfiles/i3.conf | 189 ------------------------------------------------- common.nix | 56 +-------------- modules/i3/default.nix | 56 +++++++++++++++ modules/i3/i3.conf | 189 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 247 insertions(+), 243 deletions(-) delete mode 100644 cfgfiles/i3.conf create mode 100644 modules/i3/default.nix create mode 100644 modules/i3/i3.conf diff --git a/cfgfiles/i3.conf b/cfgfiles/i3.conf deleted file mode 100644 index 6ae4a3a7..00000000 --- a/cfgfiles/i3.conf +++ /dev/null @@ -1,189 +0,0 @@ -# default modifier key -set $mod Mod4 - -# we want to have a VT-style font :-) -font -dosemu-vga-medium-r-normal--17-160-75-75-c-80-ibm-cp866 - -# Use Mouse+$mod to drag floating windows to their wanted position -floating_modifier $mod - -# reasonable defaults! -default_orientation horizontal -workspace_layout tabbed -popup_during_fullscreen ignore - -# start a terminal -bindsym $mod+Shift+Return exec --no-startup-id @xterm@/bin/xterm - -# kill focused window -bindsym $mod+Shift+C kill - -# start dmenu (a program launcher) -bindsym $mod+p exec --no-startup-id @dmenu@/bin/dmenu_run - -# set background -exec @xsetroot@/bin/xsetroot -solid black - -# audio controls -bindsym XF86AudioLowerVolume exec @pvolctrl@/bin/pvolctrl -10 -bindsym XF86AudioRaiseVolume exec @pvolctrl@/bin/pvolctrl 10 -bindsym XF86AudioMute exec @pvolctrl@/bin/pvolctrl 0 - -# change/move focus -bindsym $mod+Shift+Left move left -bindsym $mod+Shift+H move left -bindsym $mod+Shift+Down move down -bindsym $mod+Shift+T move down -bindsym $mod+Shift+Up move up -bindsym $mod+Shift+N move up -bindsym $mod+Shift+Right move right -bindsym $mod+Shift+S move right - -bindsym $mod+Left focus left -bindsym $mod+h focus left -bindsym $mod+Down focus down -bindsym $mod+t focus down -bindsym $mod+Up focus up -bindsym $mod+n focus up -bindsym $mod+Right focus right -bindsym $mod+s focus right - -# split in horizontal orientation -bindsym $mod+i split h - -# split in vertical orientation -bindsym $mod+d split v - -# enter fullscreen mode for the focused container -bindsym $mod+f fullscreen - -# change container layout (stacked, tabbed, default) -bindsym $mod+apostrophe layout stacking -bindsym $mod+comma layout tabbed -bindsym $mod+period layout default - -# toggle tiling / floating -bindsym $mod+Shift+space floating toggle - -# change focus between tiling / floating windows -bindsym $mod+space focus mode_toggle - -# focus the parent container -bindsym $mod+a focus parent - -# focus the child container -bindsym $mod+semicolon focus child - -# switch to workspace -bindsym $mod+1 workspace "@ws1@" -bindsym $mod+2 workspace "@ws2@" -bindsym $mod+3 workspace "@ws3@" -bindsym $mod+4 workspace "@ws4@" -bindsym $mod+5 workspace "@ws5@" -bindsym $mod+6 workspace "@ws6@" -bindsym $mod+7 workspace "@ws7@" -bindsym $mod+8 workspace "@ws8@" -bindsym $mod+9 workspace "@ws9@" -bindsym $mod+0 workspace "@ws10@" - -# move focused container to workspace -bindsym $mod+Shift+exclam move workspace "@ws1@" -bindsym $mod+Shift+at move workspace "@ws2@" -bindsym $mod+Shift+numbersign move workspace "@ws3@" -bindsym $mod+Shift+dollar move workspace "@ws4@" -bindsym $mod+Shift+percent move workspace "@ws5@" -bindsym $mod+Shift+asciicircum move workspace "@ws6@" -bindsym $mod+Shift+ampersand move workspace "@ws7@" -bindsym $mod+Shift+asterisk move workspace "@ws8@" -bindsym $mod+Shift+parenleft move workspace "@ws9@" -bindsym $mod+Shift+parenright move workspace "@ws10@" - -# reload the configuration file -bindsym $mod+Shift+L reload -# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) -bindsym $mod+Shift+R restart -# exit i3 (logs you out of your X session) -bindsym $mod+Shift+Q exit - -# resize window (you can also use the mouse for that) -mode "resize" { - # These bindings trigger as soon as you enter the resize mode - - # They resize the border in the direction you pressed, e.g. - # when pressing left, the window is resized so that it has - # more space on its left - - bindsym Left resize shrink left 10 px or 10 ppt - bindsym h resize shrink left 10 px or 10 ppt - bindsym Down resize shrink down 10 px or 10 ppt - bindsym t resize shrink down 10 px or 10 ppt - bindsym Up resize shrink up 10 px or 10 ppt - bindsym n resize shrink up 10 px or 10 ppt - bindsym Right resize shrink right 10 px or 10 ppt - bindsym s resize shrink right 10 px or 10 ppt - - bindsym Shift+Left resize grow left 10 px or 10 ppt - bindsym Shift+H resize grow left 10 px or 10 ppt - bindsym Shift+Down resize grow down 10 px or 10 ppt - bindsym Shift+T resize grow down 10 px or 10 ppt - bindsym Shift+Up resize grow up 10 px or 10 ppt - bindsym Shift+N resize grow up 10 px or 10 ppt - bindsym Shift+Right resize grow right 10 px or 10 ppt - bindsym Shift+S resize grow right 10 px or 10 ppt - - # back to normal: Enter or Escape - bindsym Return mode "default" - bindsym Escape mode "default" -} - -bindsym $mod+r mode "resize" - -# workspace assignments -workspace "@ws1@" output @leftHead@ -workspace "@ws2@" output @leftHead@ -workspace "@ws3@" output @leftHead@ -workspace "@ws4@" output @leftHead@ -workspace "@ws5@" output @leftHead@ -workspace "@ws6@" output @rightHead@ -workspace "@ws7@" output @rightHead@ -workspace "@ws8@" output @rightHead@ -workspace "@ws9@" output @rightHead@ -workspace "@ws10@" output @rightHead@ - -# default applications -assign [class="^Tkabber$"] 1: tkabber -#exec --no-startup-id tkabber -assign [class="^Chromium(?:-browser)?$"] 3: chromium -#exec chromium - -# ratmenu should be as unintrusive as possible -for_window [class="^ratmenu$"] floating enable -for_window [class="^ratmenu$"] border none - -# various app cruft -for_window [class="^Dia$"] floating enable - -# bar configuration -bar { - output @leftHead@ - status_command @conky@/bin/conky -c "@conkyrc@" -t 'CPU: ${cpu cpu1}% ${cpu cpu2}% ${cpu cpu3}% ${cpu cpu4}% ${cpu cpu5}% ${cpu cpu6}% ${cpu cpu7}% ${cpu cpu8}% - ${cpu cpu0}% | MEM: $mem/$memmax - $memperc% | SWAP: $swap/$swapmax $swapperc% | ${time %a %b %d %T %Z %Y}' - - colors { - focused_workspace #5c5cff #e5e5e5 - active_workspace #ffffff #0000ee - inactive_workspace #00cdcd #0000ee - urgent_workspace #ffff00 #cd0000 - } -} - -bar { - output @rightHead@ - status_command @conky@/bin/conky -c "@conkyrc@" -t 'NET: ${upspeed @primaryNetInterface@} ${downspeed @primaryNetInterface@} | DF: ${fs_used /}/${fs_size /} | LAVG: $loadavg | TEMP - CPU: ${platform coretemp.0 temp 2}C ${platform coretemp.0 temp 3}C ${platform coretemp.0 temp 4}C ${platform coretemp.0 temp 5}C - GPU: ${hwmon 0 temp 1}C - OUTSIDE: ${weather http://weather.noaa.gov/pub/data/observations/metar/stations/ EDMA temperature}C | ${time %a %b %d %T %Z %Y}' - - colors { - focused_workspace #5c5cff #e5e5e5 - active_workspace #ffffff #0000ee - inactive_workspace #00cdcd #0000ee - urgent_workspace #ffff00 #cd0000 - } -} diff --git a/common.nix b/common.nix index 0796ae98..0892a72a 100644 --- a/common.nix +++ b/common.nix @@ -1,7 +1,8 @@ {config, pkgs, ...}: { - require = [ + imports = [ + ./modules/i3 ]; nix = { @@ -114,59 +115,6 @@ ${pkgs.redshift}/bin/redshift -l 48.428404:10.866007 & ''; - windowManager = { - default = "i3"; - - i3.enable = true; - i3.configFile = with pkgs.lib; pkgs.substituteAll ({ - name = "i3.conf"; - src = ./cfgfiles/i3.conf; - - inherit (pkgs) conky dmenu xterm pvolctrl; - inherit (pkgs.xorg) xsetroot; - leftHead = head config.services.xserver.xrandrHeads; - rightHead = last config.services.xserver.xrandrHeads; - - primaryNetInterface = "enp0s25"; - - conkyrc = pkgs.writeText "conkyrc" '' - cpu_avg_samples 2 - net_avg_samples 2 - no_buffers yes - out_to_console yes - out_to_ncurses no - out_to_stderr no - extra_newline no - update_interval 1.0 - uppercase no - use_spacer none - pad_percents 3 - use_spacer left - TEXT - ''; - } // (let - # Workaround for Synergy: we need to have polarizing heads. - leftHead = head config.services.xserver.xrandrHeads; - rightHead = last config.services.xserver.xrandrHeads; - in if config.networking.hostName == "mmrnmhrm" - then { inherit leftHead rightHead; } - else { leftHead = rightHead; rightHead = leftHead; } - ) // (let - wsConfig = if config.networking.hostName == "mmrnmhrm" - then [ "XMPP" null "chromium" null null - null null null null null ] - else [ "chromium" null null null null - null null null null null ]; - - mkWsName = num: name: let - mkPair = nameValuePair "ws${toString num}"; - in if name == null - then mkPair (toString num) - else mkPair "${toString num}: ${name}"; - - in listToAttrs (imap mkWsName wsConfig))); - }; - desktopManager.default = "none"; desktopManager.xterm.enable = false; diff --git a/modules/i3/default.nix b/modules/i3/default.nix new file mode 100644 index 00000000..99849bf4 --- /dev/null +++ b/modules/i3/default.nix @@ -0,0 +1,56 @@ +{ pkgs, config, ... }: + +{ + services.xserver.windowManager = { + default = "i3"; + + i3.enable = true; + i3.configFile = with pkgs.lib; pkgs.substituteAll ({ + name = "i3.conf"; + src = ./i3.conf; + + inherit (pkgs) conky dmenu xterm pvolctrl; + inherit (pkgs.xorg) xsetroot; + leftHead = head config.services.xserver.xrandrHeads; + rightHead = last config.services.xserver.xrandrHeads; + + primaryNetInterface = "enp0s25"; + + conkyrc = pkgs.writeText "conkyrc" '' + cpu_avg_samples 2 + net_avg_samples 2 + no_buffers yes + out_to_console yes + out_to_ncurses no + out_to_stderr no + extra_newline no + update_interval 1.0 + uppercase no + use_spacer none + pad_percents 3 + use_spacer left + TEXT + ''; + } // (let + # Workaround for Synergy: we need to have polarizing heads. + leftHead = head config.services.xserver.xrandrHeads; + rightHead = last config.services.xserver.xrandrHeads; + in if config.networking.hostName == "mmrnmhrm" + then { inherit leftHead rightHead; } + else { leftHead = rightHead; rightHead = leftHead; } + ) // (let + wsConfig = if config.networking.hostName == "mmrnmhrm" + then [ "XMPP" null "chromium" null null + null null null null null ] + else [ "chromium" null null null null + null null null null null ]; + + mkWsName = num: name: let + mkPair = nameValuePair "ws${toString num}"; + in if name == null + then mkPair (toString num) + else mkPair "${toString num}: ${name}"; + + in listToAttrs (imap mkWsName wsConfig))); + }; +} diff --git a/modules/i3/i3.conf b/modules/i3/i3.conf new file mode 100644 index 00000000..6ae4a3a7 --- /dev/null +++ b/modules/i3/i3.conf @@ -0,0 +1,189 @@ +# default modifier key +set $mod Mod4 + +# we want to have a VT-style font :-) +font -dosemu-vga-medium-r-normal--17-160-75-75-c-80-ibm-cp866 + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod + +# reasonable defaults! +default_orientation horizontal +workspace_layout tabbed +popup_during_fullscreen ignore + +# start a terminal +bindsym $mod+Shift+Return exec --no-startup-id @xterm@/bin/xterm + +# kill focused window +bindsym $mod+Shift+C kill + +# start dmenu (a program launcher) +bindsym $mod+p exec --no-startup-id @dmenu@/bin/dmenu_run + +# set background +exec @xsetroot@/bin/xsetroot -solid black + +# audio controls +bindsym XF86AudioLowerVolume exec @pvolctrl@/bin/pvolctrl -10 +bindsym XF86AudioRaiseVolume exec @pvolctrl@/bin/pvolctrl 10 +bindsym XF86AudioMute exec @pvolctrl@/bin/pvolctrl 0 + +# change/move focus +bindsym $mod+Shift+Left move left +bindsym $mod+Shift+H move left +bindsym $mod+Shift+Down move down +bindsym $mod+Shift+T move down +bindsym $mod+Shift+Up move up +bindsym $mod+Shift+N move up +bindsym $mod+Shift+Right move right +bindsym $mod+Shift+S move right + +bindsym $mod+Left focus left +bindsym $mod+h focus left +bindsym $mod+Down focus down +bindsym $mod+t focus down +bindsym $mod+Up focus up +bindsym $mod+n focus up +bindsym $mod+Right focus right +bindsym $mod+s focus right + +# split in horizontal orientation +bindsym $mod+i split h + +# split in vertical orientation +bindsym $mod+d split v + +# enter fullscreen mode for the focused container +bindsym $mod+f fullscreen + +# change container layout (stacked, tabbed, default) +bindsym $mod+apostrophe layout stacking +bindsym $mod+comma layout tabbed +bindsym $mod+period layout default + +# toggle tiling / floating +bindsym $mod+Shift+space floating toggle + +# change focus between tiling / floating windows +bindsym $mod+space focus mode_toggle + +# focus the parent container +bindsym $mod+a focus parent + +# focus the child container +bindsym $mod+semicolon focus child + +# switch to workspace +bindsym $mod+1 workspace "@ws1@" +bindsym $mod+2 workspace "@ws2@" +bindsym $mod+3 workspace "@ws3@" +bindsym $mod+4 workspace "@ws4@" +bindsym $mod+5 workspace "@ws5@" +bindsym $mod+6 workspace "@ws6@" +bindsym $mod+7 workspace "@ws7@" +bindsym $mod+8 workspace "@ws8@" +bindsym $mod+9 workspace "@ws9@" +bindsym $mod+0 workspace "@ws10@" + +# move focused container to workspace +bindsym $mod+Shift+exclam move workspace "@ws1@" +bindsym $mod+Shift+at move workspace "@ws2@" +bindsym $mod+Shift+numbersign move workspace "@ws3@" +bindsym $mod+Shift+dollar move workspace "@ws4@" +bindsym $mod+Shift+percent move workspace "@ws5@" +bindsym $mod+Shift+asciicircum move workspace "@ws6@" +bindsym $mod+Shift+ampersand move workspace "@ws7@" +bindsym $mod+Shift+asterisk move workspace "@ws8@" +bindsym $mod+Shift+parenleft move workspace "@ws9@" +bindsym $mod+Shift+parenright move workspace "@ws10@" + +# reload the configuration file +bindsym $mod+Shift+L reload +# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) +bindsym $mod+Shift+R restart +# exit i3 (logs you out of your X session) +bindsym $mod+Shift+Q exit + +# resize window (you can also use the mouse for that) +mode "resize" { + # These bindings trigger as soon as you enter the resize mode + + # They resize the border in the direction you pressed, e.g. + # when pressing left, the window is resized so that it has + # more space on its left + + bindsym Left resize shrink left 10 px or 10 ppt + bindsym h resize shrink left 10 px or 10 ppt + bindsym Down resize shrink down 10 px or 10 ppt + bindsym t resize shrink down 10 px or 10 ppt + bindsym Up resize shrink up 10 px or 10 ppt + bindsym n resize shrink up 10 px or 10 ppt + bindsym Right resize shrink right 10 px or 10 ppt + bindsym s resize shrink right 10 px or 10 ppt + + bindsym Shift+Left resize grow left 10 px or 10 ppt + bindsym Shift+H resize grow left 10 px or 10 ppt + bindsym Shift+Down resize grow down 10 px or 10 ppt + bindsym Shift+T resize grow down 10 px or 10 ppt + bindsym Shift+Up resize grow up 10 px or 10 ppt + bindsym Shift+N resize grow up 10 px or 10 ppt + bindsym Shift+Right resize grow right 10 px or 10 ppt + bindsym Shift+S resize grow right 10 px or 10 ppt + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} + +bindsym $mod+r mode "resize" + +# workspace assignments +workspace "@ws1@" output @leftHead@ +workspace "@ws2@" output @leftHead@ +workspace "@ws3@" output @leftHead@ +workspace "@ws4@" output @leftHead@ +workspace "@ws5@" output @leftHead@ +workspace "@ws6@" output @rightHead@ +workspace "@ws7@" output @rightHead@ +workspace "@ws8@" output @rightHead@ +workspace "@ws9@" output @rightHead@ +workspace "@ws10@" output @rightHead@ + +# default applications +assign [class="^Tkabber$"] 1: tkabber +#exec --no-startup-id tkabber +assign [class="^Chromium(?:-browser)?$"] 3: chromium +#exec chromium + +# ratmenu should be as unintrusive as possible +for_window [class="^ratmenu$"] floating enable +for_window [class="^ratmenu$"] border none + +# various app cruft +for_window [class="^Dia$"] floating enable + +# bar configuration +bar { + output @leftHead@ + status_command @conky@/bin/conky -c "@conkyrc@" -t 'CPU: ${cpu cpu1}% ${cpu cpu2}% ${cpu cpu3}% ${cpu cpu4}% ${cpu cpu5}% ${cpu cpu6}% ${cpu cpu7}% ${cpu cpu8}% - ${cpu cpu0}% | MEM: $mem/$memmax - $memperc% | SWAP: $swap/$swapmax $swapperc% | ${time %a %b %d %T %Z %Y}' + + colors { + focused_workspace #5c5cff #e5e5e5 + active_workspace #ffffff #0000ee + inactive_workspace #00cdcd #0000ee + urgent_workspace #ffff00 #cd0000 + } +} + +bar { + output @rightHead@ + status_command @conky@/bin/conky -c "@conkyrc@" -t 'NET: ${upspeed @primaryNetInterface@} ${downspeed @primaryNetInterface@} | DF: ${fs_used /}/${fs_size /} | LAVG: $loadavg | TEMP - CPU: ${platform coretemp.0 temp 2}C ${platform coretemp.0 temp 3}C ${platform coretemp.0 temp 4}C ${platform coretemp.0 temp 5}C - GPU: ${hwmon 0 temp 1}C - OUTSIDE: ${weather http://weather.noaa.gov/pub/data/observations/metar/stations/ EDMA temperature}C | ${time %a %b %d %T %Z %Y}' + + colors { + focused_workspace #5c5cff #e5e5e5 + active_workspace #ffffff #0000ee + inactive_workspace #00cdcd #0000ee + urgent_workspace #ffff00 #cd0000 + } +} -- cgit 1.4.1