From 6b456c1b7a4f6899f063a6e65355af51901d9c7a Mon Sep 17 00:00:00 2001 From: William Carroll Date: Wed, 9 Oct 2019 12:13:56 +0100 Subject: Massive configuration overhaul Currently paying the price of months of non-diligent git usage. Here's what has changed. - Theming support in Gvcci and wpgtk - Dropping support for i3 - Supporting EXWM - Many Elisp modules - Collapsed redundant directories in ./configs --- configs/shared/.config/compton.conf | 33 + configs/shared/.config/i3/config | 329 ++++++++++ configs/shared/.config/i3/config.bak | 330 ++++++++++ configs/shared/.config/i3/dmenu_timer.sh | 113 ++++ configs/shared/.config/i3/passmenu | 25 + configs/shared/.config/i3/workspace_1.json | 76 +++ configs/shared/.config/i3status/config | 58 ++ configs/shared/.config/lf/lfrc | 163 +++++ configs/shared/.config/lf/marks | 7 + configs/shared/.config/mpd/database | Bin 0 -> 247 bytes configs/shared/.config/mpd/mpd.conf | 4 + configs/shared/.config/nixpkgs/config.nix | 3 + configs/shared/.config/nvim/init.vim | 669 +++++++++++++++++++++ configs/shared/.config/nvim/simple.vim | 98 +++ .../shared/.config/nvim/templates/boilerplate.c | 6 + .../shared/.config/nvim/templates/boilerplate.rs | 5 + configs/shared/.config/rofi/config | 6 + configs/shared/.config/rofi/config.bak | 6 + .../shared/.config/systemd/user/clipmenud.service | 18 + .../user/default.target.wants/clipmenud.service | 1 + configs/shared/.config/terminator/config | 34 ++ configs/shared/.config/terminator/config.bak | 23 + .../terminator/plugins/terminator-themes.py | 250 ++++++++ 23 files changed, 2257 insertions(+) create mode 100644 configs/shared/.config/compton.conf create mode 100644 configs/shared/.config/i3/config create mode 100644 configs/shared/.config/i3/config.bak create mode 100755 configs/shared/.config/i3/dmenu_timer.sh create mode 100755 configs/shared/.config/i3/passmenu create mode 100644 configs/shared/.config/i3/workspace_1.json create mode 100644 configs/shared/.config/i3status/config create mode 100644 configs/shared/.config/lf/lfrc create mode 100644 configs/shared/.config/lf/marks create mode 100644 configs/shared/.config/mpd/database create mode 100644 configs/shared/.config/mpd/mpd.conf create mode 100644 configs/shared/.config/nixpkgs/config.nix create mode 100644 configs/shared/.config/nvim/init.vim create mode 100644 configs/shared/.config/nvim/simple.vim create mode 100644 configs/shared/.config/nvim/templates/boilerplate.c create mode 100644 configs/shared/.config/nvim/templates/boilerplate.rs create mode 100644 configs/shared/.config/rofi/config create mode 100644 configs/shared/.config/rofi/config.bak create mode 100644 configs/shared/.config/systemd/user/clipmenud.service create mode 120000 configs/shared/.config/systemd/user/default.target.wants/clipmenud.service create mode 100644 configs/shared/.config/terminator/config create mode 100644 configs/shared/.config/terminator/config.bak create mode 100644 configs/shared/.config/terminator/plugins/terminator-themes.py (limited to 'configs/shared/.config') diff --git a/configs/shared/.config/compton.conf b/configs/shared/.config/compton.conf new file mode 100644 index 000000000000..a6b5f637e60a --- /dev/null +++ b/configs/shared/.config/compton.conf @@ -0,0 +1,33 @@ +# shadow +shadow = false; +shadow-radius = 7; +shadow-offset-x = -7; +shadow-offset-y = -7; + +# TODO: Remove active opacity + +# opacity +menu-opacity = 0.8; +inactive-opacity = 0.96; +active-opacity = 0.96; + +# transitions +fading = true; +fade-in-step = 0.07; +fade-out-step = 0.07; + +# lock screen +# NOTE: Need this rule here because I set XSECURELOCK_NO_COMPOSITE=1 in +# ~/.profile. Without this, the lock screen will adopt the opacity settings +# above, which is a security risk if you lock your screen while it has sensitive +# content on it. +# +# NOTE: For some reason, `100:class_g` doesn't work, so settling for +# `99:class_g` instead. +opacity-rule = [ + "99:class_g = 'xsecurelock'", + # TODO: Ensure this works. + "80:class_g = 'terminator'", + # TODO: Ensure this work. + "80:class_g = 'Google Emacs'" +]; diff --git a/configs/shared/.config/i3/config b/configs/shared/.config/i3/config new file mode 100644 index 000000000000..e52bf23b3d96 --- /dev/null +++ b/configs/shared/.config/i3/config @@ -0,0 +1,329 @@ +# Keymapping philosophy: +# When I feel it's appropriate, I try to borrow existing KBDs from OSX or +# Windows. For example, I use Ctrl+Alt+Del to start the screen lock, since this +# is a really well-known KBD. One notable difference is that when I'm borrowing +# OSX KBDs, I prefer using Alt instead of Super since the keyboard that I'm +# using has the Alt key in the same location as the Super key on my mac +# keyboard. I could rebind this, and I just may. But for now, that's worth +# pointing out. +# The reason behind borrowing from Windows and OSX is that some of these +# keybindings are hardwired into my muscle memory. I also tend to work between +# Linux and OSX quite often. Since OSX is much more difficult to remap KBDs +# than it is in Linux, I prefer to support the OSX KBDs to reduce the number of +# KBDs my feeble memory needs to store. + +set $mod Mod1 +set $window Mod1+Ctrl +set $super Mod4 +set $terminal terminator +set $browser google-chrome + +# 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 10px + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod + +# i3-gaps (depends on i3-gaps installation) +# gaps inner 7 +# gaps outer 0 +# smart_gaps on +# +# bindsym $mod+Ctrl+plus gaps outer current plus 5 +# bindsym $mod+Ctrl+minus gaps outer current minus 5 +# bindsym $mod+Shift+plus gaps inner current plus 5 +# bindsym $mod+Shift+minus gaps inner current minus 5 + +# Support XF86 keys for audio playback and volume control +bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle +bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% +bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% +bindsym XF86AudioPrev exec --no-startup-id playerctl previous +bindsym XF86AudioNext exec --no-startup-id playerctl next +bindsym XF86AudioStop exec --no-startup-id playerctl play-pause +bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause + +# KBD Principles: +# $mod+Ctrl+ = starting an application +# where is a reserved character for a commonly used application. +# +# definitions: +# terminal = t, Return +# emacs = e +# chrome = c +# spotify = s +# intellij = i +bindsym $mod+Ctrl+t exec $terminal +bindsym $mod+Return exec $terminal +bindsym $mod+Ctrl+e exec emacsclient --create-frame +bindsym $mod+Ctrl+c exec $browser +bindsym $mod+Ctrl+s exec spotify +bindsym $mod+Ctrl+i exec zsh -i -c intellij + +# support dmenu-based bookmarks +# bindsym $mod+Ctrl+b exec rofi -dmenu <$DOTFILES/bookmarks.txt | xargs $browser + +set $bookmarks_mode Bookmarks (a) add, (d) delete, (b) browse +mode "$bookmarks_mode" { + bindsym a exec zsh -i -c add_bookmark, mode "default" + bindsym d exec zsh -i -c rm_bookmark, mode "default" + bindsym b exec zsh -i -c open_bookmark, mode "default" + + bindsym Escape mode "default" + bindsym Ctrl+g mode "default" + bindsym Ctrl+c mode "default" +} +bindsym $mod+Ctrl+b mode "$bookmarks_mode" + +# pass integration +bindsym $mod+Ctrl+backslash exec ~/.config/i3/passmenu # mirroring the 1password KBD + +# integrate with Emacs's org-mode +bindsym $mod+o exec zsh -i -c org_capture +# TODO: Support "coding size", "dialog-size" (for org_capture) +# TODO: Support way to cycle through predefined sizes. +for_window [class="GoogleEmacs" instance="floating"] floating enable, resize set height 1200px, resize set width 780px + +# Here is a sketch of the cycle sizes idea. +# TODO: Support this. +# mode "cycle_sizes_floating_mode" { +# # coding mode +# bindsym a for_window [mode="floating", class="actively-selected"] resize set height 1200px, resize set width 780px +# bindsym b for_window [mode="floating", class="actively-selected"] resize set height 500px, resize set width 500px +# +# bindsym Escape mode "default" +# bindsym Ctrl+g mode "default" +# bindsym Ctrl+c mode "default" +# } + +# ensure Spotify windows float +for_window [class="Spotify"] floating enable + +# ensure system service that run through XDG start +exec --no-startup-id dex -ae i3 + +# rofi configuration +bindsym $mod+space exec --no-startup-id rofi -show combi +bindsym $mod+t exec --no-startup-id ~/.config/i3/dmenu_timer.sh ~/.local/share/sounds/gong.mp3 + +# switch workspaces +bindsym $mod+Tab workspace next +bindsym $mod+Shift+Tab workspace prev + +# file manager +bindsym $mod+n exec $terminal -x lf ~/Dropbox + +# clipboard manager +# NOTE: Ctrl-c is already covered since `clipmenu` listens for X clipboard +# events using `clipnotify`. +# NOTE: `clipmenud` is started in `.xsessionrc.shared` +# NOTE: This is a bit of a hack intended to support pasting in both the terminal +# and in GUI applications. `st` expects `ctrl+Shift+v` while GUIs expect +# `ctrl+v`. In the instances where GUIs don't support `ctrl+Shift+v` already, it +# acts like `ctrl+v`, so it should "just work". +bindsym Ctrl+$mod+v exec clipmenu && xdotool key --clearmodifiers ctrl+Shift+v + +# Screenshot +# TODO: Support variants: (a) App (r) Region (f) Fullscreen. +# TODO: Support hosting to third-party image hosting. +set $screenshot_mode Screenshot (g) googleplex (l) local +mode "$screenshot_mode" { + bindsym g exec zsh -i -c snipit, mode "default" + bindsym l exec zsh -i -c screenshot, mode "default" + + bindsym Escape mode "default" + bindsym Ctrl+g mode "default" + bindsym Ctrl+c mode "default" +} +bindsym $mod+s mode "$screenshot_mode" + +# online documentation +bindsym $mod+Shift+slash exec $browser https://i3wm.org/docs/userguide.html + +# no title bars +for_window [class="^.*"] border pixel 1 + +# disable mouse hover focus +focus_follows_mouse no + +# kill focused window +bindsym $window+q kill + +# Toggle focus +bindsym $window+f floating toggle + +# GTK Themes +exec --no-startup-id gnome-settings-daemon + +# wireless selection mechanism +exec --no-startup-id nm-applet + +# set the split direction +bindsym $mod+v split vertical +# cannot bind $mod+h because of movement commands +bindsym $mod+Shift+v split horizontal + +# sound applet +exec --no-startup-id gnome-sound-applet + +# change focus +bindsym $window+h focus left +bindsym $window+j focus down +bindsym $window+k focus up +bindsym $window+l focus right + +# move focused window +bindsym $mod+Shift+h move left 100 +bindsym $mod+Shift+j move down 100 +bindsym $mod+Shift+k move up 100 +bindsym $mod+Shift+l move right 100 + +# enter fullscreen mode for the focused container +bindsym $window+z fullscreen toggle + +# change container layout (stacked, tabbed, toggle split) +bindsym $super+e layout toggle split +bindsym $super+s layout stacking +bindsym $super+t layout tabbed + +# toggle tiling / floating +bindsym $mod+Shift+f floating toggle + +# toggle stickiness +bindsym $mod+Shift+s sticky toggle + +# focus the parent container +# bindsym $mod+a focus parent +bindsym $mod+Shift+a focus child + +# Define names for default workspaces for which we configure key bindings later on. +# We use variables to avoid repeating the names in multiple places. +set $ws1 "1" +set $ws2 "2" +set $ws3 "3" +set $ws4 "4" +set $ws5 "5" +set $ws6 "6" +set $ws7 "7" +set $ws8 "8" +set $ws9 "9" +set $ws10 "10" + +# jump 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 + +# edit configuration files +# TODO: Standardize KBDs for C,R,U,D operations. +# TODO: Move shell script to /usr/local/bin +# Create +# TODO: Choose another KBD. This is temporary. +bindsym $mod+a exec zsh -i -c add_config +# Read +bindsym $mod+c exec zsh -i -c edit_config +# Update +# TODO: Support operation to update_config label and path +# Delete +bindsym $mod+Shift+c exec zsh -i -c rm_config + +# move and follow focused container to workspace +bindsym $mod+Shift+1 move container to workspace $ws1; workspace $ws1 +bindsym $mod+Shift+2 move container to workspace $ws2; workspace $ws2 +bindsym $mod+Shift+3 move container to workspace $ws3; workspace $ws3 +bindsym $mod+Shift+4 move container to workspace $ws4; workspace $ws4 +bindsym $mod+Shift+5 move container to workspace $ws5; workspace $ws5 +bindsym $mod+Shift+6 move container to workspace $ws6; workspace $ws6 +bindsym $mod+Shift+7 move container to workspace $ws7; workspace $ws7 +bindsym $mod+Shift+8 move container to workspace $ws8; workspace $ws8 +bindsym $mod+Shift+9 move container to workspace $ws9; workspace $ws9 +bindsym $mod+Shift+0 move container to workspace $ws10; workspace $ws10 + +# move focused container to workspace +bindsym $mod+Ctrl+1 move container to workspace $ws1 +bindsym $mod+Ctrl+2 move container to workspace $ws2 +bindsym $mod+Ctrl+3 move container to workspace $ws3 +bindsym $mod+Ctrl+4 move container to workspace $ws4 +bindsym $mod+Ctrl+5 move container to workspace $ws5 +bindsym $mod+Ctrl+6 move container to workspace $ws6 +bindsym $mod+Ctrl+7 move container to workspace $ws7 +bindsym $mod+Ctrl+8 move container to workspace $ws8 +bindsym $mod+Ctrl+9 move container to workspace $ws9 +bindsym $mod+Ctrl+0 move container to workspace $ws10 + +# reload, restart i3 +bindsym $super+r exec cat ~/.config/i3/config.shared ~/.config/i3/config.device >~/.config/i3/config; reload +bindsym $super+Shift+r exec cat ~/.config/i3/config.shared ~/.config/i3/config.device >~/.config/i3/config; restart + +# logout dialog +set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown +mode "$mode_system" { + bindsym l exec --no-startup-id xsecurelock, mode "default" + bindsym e exit, mode "default" + bindsym s exec --no-startup-id xsecurelock && systemctl suspend, mode "default" + bindsym h exec --no-startup-id xsecurelock && systemctl hibernate, mode "default" + bindsym r exec --no-startup-id systemctl reboot, mode "default" + bindsym Shift+s exec --no-startup-id systemctl poweroff, mode "default" + + # back to normal: Enter or Escape + bindsym Escape mode "default" + bindsym Ctrl+g mode "default" + bindsym Ctrl+c mode "default" +} +bindsym Ctrl+Mod1+Delete mode "$mode_system" + +# resize window (you can also use the mouse for that) +mode "resize" { + bindsym h resize shrink width 10 px or 10 ppt + bindsym j resize shrink height 10 px or 10 ppt + bindsym k resize grow height 10 px or 10 ppt + bindsym l resize grow width 10 px or 10 ppt + + bindsym Escape mode "default" + bindsym Ctrl+g mode "default" + bindsym Ctrl+c mode "default" +} +bindsym $mod+Shift+r mode "resize" + +# passthrough mode to support Emacs, Tmux, Vim KBDs for window and pane management +mode "passthrough" { + bindsym $mod+Escape mode "default" +} +bindsym $mod+Escape mode "passthrough" + +# class border backgr text indicator child_border +client.focused #83526a #83526a #8de0e1 #E8C35F #83526a +client.focused_inactive #83526a #83526a #8de0e1 #E8C35F #5a3849 +client.unfocused #5a3849 #5a3849 #8de0e1 #E8C35F #5a3849 +client.urgent #E8C35F #E8C35F #8de0e1 #E8C35F #E8C35F +client.placeholder #31213f #629c9d #8de0e1 #31213f #629c9d +client.background #31213f + +bar { + status_command i3status + font pango:Monospace 10px + position top + # disable system tray icons + tray_output none + colors { + background #31213f + statusline #83526a # text color in status line + separator #83526a + # class border text indicator + focused_workspace #83526a #8de0e1 #31213f + active_workspace #83526a #5a3849 #83526a + inactive_workspace #5a3849 #83526a #5a3849 + urgent_workspace #5a3849 #83526a #5a3849 + } +} + +# wpg integration +exec --no-startup-id ~/.config/wpg/wp_init.sh \ No newline at end of file diff --git a/configs/shared/.config/i3/config.bak b/configs/shared/.config/i3/config.bak new file mode 100644 index 000000000000..ccfae1d453b8 --- /dev/null +++ b/configs/shared/.config/i3/config.bak @@ -0,0 +1,330 @@ +# Keymapping philosophy: +# When I feel it's appropriate, I try to borrow existing KBDs from OSX or +# Windows. For example, I use Ctrl+Alt+Del to start the screen lock, since this +# is a really well-known KBD. One notable difference is that when I'm borrowing +# OSX KBDs, I prefer using Alt instead of Super since the keyboard that I'm +# using has the Alt key in the same location as the Super key on my mac +# keyboard. I could rebind this, and I just may. But for now, that's worth +# pointing out. +# The reason behind borrowing from Windows and OSX is that some of these +# keybindings are hardwired into my muscle memory. I also tend to work between +# Linux and OSX quite often. Since OSX is much more difficult to remap KBDs +# than it is in Linux, I prefer to support the OSX KBDs to reduce the number of +# KBDs my feeble memory needs to store. + +set $mod Mod1 +set $window Mod1+Ctrl +set $super Mod4 +# TODO: Support alacritty or another fast terminal. +set $terminal terminator +set $browser google-chrome + +# 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 10px + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod + +# i3-gaps (depends on i3-gaps installation) +# gaps inner 7 +# gaps outer 0 +# smart_gaps on +# +# bindsym $mod+Ctrl+plus gaps outer current plus 5 +# bindsym $mod+Ctrl+minus gaps outer current minus 5 +# bindsym $mod+Shift+plus gaps inner current plus 5 +# bindsym $mod+Shift+minus gaps inner current minus 5 + +# Support XF86 keys for audio playback and volume control +bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle +bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% +bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% +bindsym XF86AudioPrev exec --no-startup-id playerctl previous +bindsym XF86AudioNext exec --no-startup-id playerctl next +bindsym XF86AudioStop exec --no-startup-id playerctl play-pause +bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause + +# KBD Principles: +# $mod+Ctrl+ = starting an application +# where is a reserved character for a commonly used application. +# +# definitions: +# terminal = t, Return +# emacs = e +# chrome = c +# spotify = s +# intellij = i +bindsym $mod+Ctrl+t exec $terminal +bindsym $mod+Return exec $terminal +bindsym $mod+Ctrl+e exec emacsclient --create-frame +bindsym $mod+Ctrl+c exec $browser +bindsym $mod+Ctrl+s exec spotify +bindsym $mod+Ctrl+i exec zsh -i -c intellij + +# support dmenu-based bookmarks +# bindsym $mod+Ctrl+b exec rofi -dmenu <$DOTFILES/bookmarks.txt | xargs $browser + +set $bookmarks_mode Bookmarks (a) add, (d) delete, (b) browse +mode "$bookmarks_mode" { + bindsym a exec zsh -i -c add_bookmark, mode "default" + bindsym d exec zsh -i -c rm_bookmark, mode "default" + bindsym b exec zsh -i -c open_bookmark, mode "default" + + bindsym Escape mode "default" + bindsym Ctrl+g mode "default" + bindsym Ctrl+c mode "default" +} +bindsym $mod+Ctrl+b mode "$bookmarks_mode" + +# pass integration +bindsym $mod+Ctrl+backslash exec ~/.config/i3/passmenu # mirroring the 1password KBD + +# integrate with Emacs's org-mode +bindsym $mod+o exec zsh -i -c org_capture +# TODO: Support "coding size", "dialog-size" (for org_capture) +# TODO: Support way to cycle through predefined sizes. +for_window [class="GoogleEmacs" instance="floating"] floating enable, resize set height 1200px, resize set width 780px + +# Here is a sketch of the cycle sizes idea. +# TODO: Support this. +# mode "cycle_sizes_floating_mode" { +# # coding mode +# bindsym a for_window [mode="floating", class="actively-selected"] resize set height 1200px, resize set width 780px +# bindsym b for_window [mode="floating", class="actively-selected"] resize set height 500px, resize set width 500px +# +# bindsym Escape mode "default" +# bindsym Ctrl+g mode "default" +# bindsym Ctrl+c mode "default" +# } + +# ensure Spotify windows float +for_window [class="Spotify"] floating enable + +# ensure system service that run through XDG start +exec --no-startup-id dex -ae i3 + +# rofi configuration +bindsym $mod+space exec --no-startup-id rofi -show combi +bindsym $mod+t exec --no-startup-id ~/.config/i3/dmenu_timer.sh ~/.local/share/sounds/gong.mp3 + +# switch workspaces +bindsym $mod+Tab workspace next +bindsym $mod+Shift+Tab workspace prev + +# file manager +bindsym $mod+n exec $terminal -x lf ~/Dropbox + +# clipboard manager +# NOTE: Ctrl-c is already covered since `clipmenu` listens for X clipboard +# events using `clipnotify`. +# NOTE: `clipmenud` is started in `.xsessionrc.shared` +# NOTE: This is a bit of a hack intended to support pasting in both the terminal +# and in GUI applications. `st` expects `ctrl+Shift+v` while GUIs expect +# `ctrl+v`. In the instances where GUIs don't support `ctrl+Shift+v` already, it +# acts like `ctrl+v`, so it should "just work". +bindsym Ctrl+$mod+v exec clipmenu && xdotool key --clearmodifiers ctrl+Shift+v + +# Screenshot +# TODO: Support variants: (a) App (r) Region (f) Fullscreen. +# TODO: Support hosting to third-party image hosting. +set $screenshot_mode Screenshot (g) googleplex (l) local +mode "$screenshot_mode" { + bindsym g exec zsh -i -c snipit, mode "default" + bindsym l exec zsh -i -c screenshot, mode "default" + + bindsym Escape mode "default" + bindsym Ctrl+g mode "default" + bindsym Ctrl+c mode "default" +} +bindsym $mod+s mode "$screenshot_mode" + +# online documentation +bindsym $mod+Shift+slash exec $browser https://i3wm.org/docs/userguide.html + +# no title bars +for_window [class="^.*"] border pixel 1 + +# disable mouse hover focus +focus_follows_mouse no + +# kill focused window +bindsym $window+q kill + +# Toggle focus +bindsym $window+f floating toggle + +# GTK Themes +exec --no-startup-id gnome-settings-daemon + +# wireless selection mechanism +exec --no-startup-id nm-applet + +# set the split direction +bindsym $mod+v split vertical +# cannot bind $mod+h because of movement commands +bindsym $mod+Shift+v split horizontal + +# sound applet +exec --no-startup-id gnome-sound-applet + +# change focus +bindsym $window+h focus left +bindsym $window+j focus down +bindsym $window+k focus up +bindsym $window+l focus right + +# move focused window +bindsym $mod+Shift+h move left 100 +bindsym $mod+Shift+j move down 100 +bindsym $mod+Shift+k move up 100 +bindsym $mod+Shift+l move right 100 + +# enter fullscreen mode for the focused container +bindsym $window+z fullscreen toggle + +# change container layout (stacked, tabbed, toggle split) +bindsym $super+e layout toggle split +bindsym $super+s layout stacking +bindsym $super+t layout tabbed + +# toggle tiling / floating +bindsym $mod+Shift+f floating toggle + +# toggle stickiness +bindsym $mod+Shift+s sticky toggle + +# focus the parent container +# bindsym $mod+a focus parent +bindsym $mod+Shift+a focus child + +# Define names for default workspaces for which we configure key bindings later on. +# We use variables to avoid repeating the names in multiple places. +set $ws1 "1" +set $ws2 "2" +set $ws3 "3" +set $ws4 "4" +set $ws5 "5" +set $ws6 "6" +set $ws7 "7" +set $ws8 "8" +set $ws9 "9" +set $ws10 "10" + +# jump 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 + +# edit configuration files +# TODO: Standardize KBDs for C,R,U,D operations. +# TODO: Move shell script to /usr/local/bin +# Create +# TODO: Choose another KBD. This is temporary. +bindsym $mod+a exec zsh -i -c add_config +# Read +bindsym $mod+c exec zsh -i -c edit_config +# Update +# TODO: Support operation to update_config label and path +# Delete +bindsym $mod+Shift+c exec zsh -i -c rm_config + +# move and follow focused container to workspace +bindsym $mod+Shift+1 move container to workspace $ws1; workspace $ws1 +bindsym $mod+Shift+2 move container to workspace $ws2; workspace $ws2 +bindsym $mod+Shift+3 move container to workspace $ws3; workspace $ws3 +bindsym $mod+Shift+4 move container to workspace $ws4; workspace $ws4 +bindsym $mod+Shift+5 move container to workspace $ws5; workspace $ws5 +bindsym $mod+Shift+6 move container to workspace $ws6; workspace $ws6 +bindsym $mod+Shift+7 move container to workspace $ws7; workspace $ws7 +bindsym $mod+Shift+8 move container to workspace $ws8; workspace $ws8 +bindsym $mod+Shift+9 move container to workspace $ws9; workspace $ws9 +bindsym $mod+Shift+0 move container to workspace $ws10; workspace $ws10 + +# move focused container to workspace +bindsym $mod+Ctrl+1 move container to workspace $ws1 +bindsym $mod+Ctrl+2 move container to workspace $ws2 +bindsym $mod+Ctrl+3 move container to workspace $ws3 +bindsym $mod+Ctrl+4 move container to workspace $ws4 +bindsym $mod+Ctrl+5 move container to workspace $ws5 +bindsym $mod+Ctrl+6 move container to workspace $ws6 +bindsym $mod+Ctrl+7 move container to workspace $ws7 +bindsym $mod+Ctrl+8 move container to workspace $ws8 +bindsym $mod+Ctrl+9 move container to workspace $ws9 +bindsym $mod+Ctrl+0 move container to workspace $ws10 + +# reload, restart i3 +bindsym $super+r exec cat ~/.config/i3/config.shared ~/.config/i3/config.device >~/.config/i3/config; reload +bindsym $super+Shift+r exec cat ~/.config/i3/config.shared ~/.config/i3/config.device >~/.config/i3/config; restart + +# logout dialog +set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown +mode "$mode_system" { + bindsym l exec --no-startup-id xsecurelock, mode "default" + bindsym e exit, mode "default" + bindsym s exec --no-startup-id xsecurelock && systemctl suspend, mode "default" + bindsym h exec --no-startup-id xsecurelock && systemctl hibernate, mode "default" + bindsym r exec --no-startup-id systemctl reboot, mode "default" + bindsym Shift+s exec --no-startup-id systemctl poweroff, mode "default" + + # back to normal: Enter or Escape + bindsym Escape mode "default" + bindsym Ctrl+g mode "default" + bindsym Ctrl+c mode "default" +} +bindsym Ctrl+Mod1+Delete mode "$mode_system" + +# resize window (you can also use the mouse for that) +mode "resize" { + bindsym h resize shrink width 10 px or 10 ppt + bindsym j resize shrink height 10 px or 10 ppt + bindsym k resize grow height 10 px or 10 ppt + bindsym l resize grow width 10 px or 10 ppt + + bindsym Escape mode "default" + bindsym Ctrl+g mode "default" + bindsym Ctrl+c mode "default" +} +bindsym $mod+Shift+r mode "resize" + +# passthrough mode to support Emacs, Tmux, Vim KBDs for window and pane management +mode "passthrough" { + bindsym $mod+Escape mode "default" +} +bindsym $mod+Escape mode "passthrough" + +# class border backgr text indicator child_border +# client.focused {active} {active} {color15} {color2} {active} +# client.focused_inactive {active} {active} {color15} {color2} {inactive} +# client.unfocused {inactive} {inactive} {color15} {color2} {inactive} +# client.urgent {color2} {color2} {color15} {color2} {color2} +# client.placeholder {color0} {color8} {color15} {color0} {color8} +# client.background {color0} + +bar { + status_command i3status + font pango:Monospace 10px + position top + # disable system tray icons + tray_output none + colors { + # background {color0} + # statusline {inactive} + # separator {active} + # class border text indicator + # focused_workspace {active} {color15} {color0} + # active_workspace {active} {inactive} {active} + # inactive_workspace {inactive} {active} {inactive} + # urgent_workspace {inactive} {active} {inactive} + } +} + +# wpg integration +exec --no-startup-id ~/.config/wpg/wp_init.sh \ No newline at end of file diff --git a/configs/shared/.config/i3/dmenu_timer.sh b/configs/shared/.config/i3/dmenu_timer.sh new file mode 100755 index 000000000000..9d62ead73091 --- /dev/null +++ b/configs/shared/.config/i3/dmenu_timer.sh @@ -0,0 +1,113 @@ +#!/usr/bin/env bash + +# Select common timer intervals with dmenu and play an alarm sound when +# finished. Useful if you bind a KBD in a window manager such as i3. Pass the +# path to the alarm mp3 as the only argument. +# +# Usage: ./dmenu_timer.sh path/to/alarm.mp3 + +times=$(cat </dev/null +else + pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | + xdotool type --clearmodifiers --file - +fi \ No newline at end of file diff --git a/configs/shared/.config/i3/workspace_1.json b/configs/shared/.config/i3/workspace_1.json new file mode 100644 index 000000000000..b5d3f9d8c53f --- /dev/null +++ b/configs/shared/.config/i3/workspace_1.json @@ -0,0 +1,76 @@ +// vim:ts=4:sw=4:et +{ + // splitv split container with 2 children + "border": "normal", + "floating": "auto_off", + "layout": "splitv", + "percent": 0.5, + "type": "con", + "nodes": [ + { + "border": "pixel", + "current_border_width": 3, + "floating": "auto_off", + "geometry": { + "height": 925, + "width": 1072, + "x": 0, + "y": 0 + }, + "name": "emacs@wpcarro.lon.corp.google.com", + "percent": 0.5, + "swallows": [ + { + "class": "^GoogleEmacs$", + "instance": "^emacs$", + "title": "^google-emacs$" + } + ], + "type": "con" + }, + { + "border": "pixel", + "current_border_width": 3, + "floating": "auto_off", + "geometry": { + "height": 484, + "width": 724, + "x": 0, + "y": 0 + }, + "name": "i3-save-tree", + "percent": 0.5, + "swallows": [ + { + "class": "^st\\-256color$", + "instance": "^st\\-256color$", + "title": "^st-term$" + } + ], + "type": "con" + } + ] +} + +{ + "border": "pixel", + "current_border_width": 3, + "floating": "auto_off", + "geometry": { + "height": 2125, + "width": 1914, + "x": 1923, + "y": 32 + }, + "name": "i3: Layout saving in i3 - Google Chrome", + "percent": 0.5, + "swallows": [ + { + "class": "^Google\\-chrome$", + "instance": "^google\\-chrome$", + "title": "Chrome", + "window_role": "^browser$" + } + ], + "type": "con" +} diff --git a/configs/shared/.config/i3status/config b/configs/shared/.config/i3status/config new file mode 100644 index 000000000000..d276046d9720 --- /dev/null +++ b/configs/shared/.config/i3status/config @@ -0,0 +1,58 @@ +general { + markup = pango + separator = " " + colors = true +} + +/* order += "battery 0" # TODO: remove this if "battery 1" works for Dell */ +order += "battery 1" # trying to support two different laptops +order += "tztime local" +order += "tztime lon" +order += "tztime est" +order += "tztime pst" +order += "disk /" + +disk "/" { + prefix_type = "decimal" + format = "%used/%total" +} + +# Useful commands for dealing with timezones: +# - cat /etc/timezone +# - man date +# - timedatectl +tztime local { + format = "%d/%m/%Y" +} + +tztime lon { + format = "LON %H:%M" + timezone = "Europe/London" +} + +tztime est { + format = "NYC %H:%M" + timezone = "US/Eastern" +} + +tztime pst { + format = "MTV %H:%M" + timezone = "US/Pacific" +} + +# TODO: remove this if "battery 1" works for Dell laptop +/* battery 0 { */ +/* format = "Battery %percentage" */ +/* format_down = "" # This hides the battery when there isn't any (e.g. on a Desktop) */ +/* low_threshold = 30 */ +/* threshold_type = time */ +/* integer_battery_capacity = true */ +/* } */ + +battery 1 { + format = "Battery %percentage" + format_down = "" # This hides the battery when there isn't any (e.g. on a Desktop) + low_threshold = 30 + threshold_type = time + integer_battery_capacity = true +} diff --git a/configs/shared/.config/lf/lfrc b/configs/shared/.config/lf/lfrc new file mode 100644 index 000000000000..f6045d2973c7 --- /dev/null +++ b/configs/shared/.config/lf/lfrc @@ -0,0 +1,163 @@ +# It might be possible to attempt to share KBDs between `lf` and `dired`. +# Currently shared KBDs with `dired`: +# - D: delete file +# - R: rename file +# - +: create directory +# - c: create file +# +# The following command prefixes are used by lf (taken from the docs): +# +# : read (default) builtin/custom command +# $ shell shell command +# % shell-pipe shell command running with the ui +# ! shell-wait shell command waiting for key press +# & shell-async shell command running asynchronously +# / search search file in current directory +# ? search-back search file in the reverse order +# +# `x` will be used as a generic prefix KBD for most of my user-defined KBDs. Do +# not map anything to just `x`. Instead prefer `x`. Mneumonically, "x" is +# intended to resemble "eXecute". +# +# If `x` does one thing; `x` should do the opposite when +# possible. This is convenient for things that pass the round-trip test like +# encrypt/decrypt, archive/unarchive. + +# TODO: move most of these commands to function.zsh and call those functions +# herein. Especially the `archive` and `extract` functions. +# +# TODO: consider integrations with `xdg-open` and configuring filetypes to +# behave in expected "dwim" ways. +# +# TODO: learn more about the terms "archive", "compress", "decompress", +# "expand", "extract", etc. See if a larger abstraction can be created on top +# without sacrificing too much nuance. This might be the case of "serialize", +# "deserialize", "pickle", "unpickle", "marshal", "unmarshal", "encode", +# "decode" -- in which case, a broader abstraction would be nice to decrease the +# surface area of the vocabulary. +# +# TODO: find a way to visualize all of the bound or unbound KBDs. +# +# TODO: support polymorphic way encrypt/decrypt a file or directory. +# +# TODO: support "toggle" for encryption/decryption that detects which function +# to run based on the extension. +# +# TODO: support "toggle" for archive/unarchive that detects which function to +# run based on the extension. + +# Basic configuration +set hidden on +set info size:time +set sortby time +set period 1 # auto-refreshes the view + +# Arguably the most import function herein +cmd help $lf -doc | less + +# delete a file, dir +map D delete + +# reload the view +map r load + +# rename files +cmd rename %[ -e $1 ] && printf 'file exists' || mv $f $1 +map R push :rename + +cmd mkdir %{{ + # mkdir and cd into that dir + mkdir -p "$1" +}} +map + push :mkdir + +cmd touch %{{ + # Create a file + touch "$1" +}} +map c push :touch # this interferes with `clear` command + +cmd encrypt %{{ + # depends on my shell function, encrypt + zsh -i -c "encrypt $f" +}} +map xe :encrypt + +cmd decrypt %{{ + # depends on my shell function, decrypt + zsh -i -c "decrypt $f" +}} +map xE :decrypt + +cmd archive %{{ + # Generic function for archiving directories. + # TODO: support selections of multiple files. + set -f + printf "Which type of archive would you like to create? (tar,tar.gz,zip) " + read answer + case $answer in + tar.gz) tar -czf "$f.tar.gz" "$(basename $f)"; rm -rf "$f";; + tar) tar -cf "$f.tar" "$(basename $f)"; rm -rf "$f";; + zip) zip -r "$f.zip" "$(basename $f)"; rm -rf "$f";; + *) printf "\"$1\" is not a support archive. Aborting..." + esac +}} +map xa :archive + +cmd unarchive %{{ + # Generic function for extracting archived directories. + # Assumes directories were archived with the `archive`. + set -f + case $f in + *.tar.gz) tar -xzvf $f; rm "$f";; + *.tar) tar -xvf $f; rm "$f";; + *.zip) unzip "$f"; rm "$f";; + # TODO: grab extension from $f and display it in `printf` call. + *) printf "Unsupported archive type. Aborting..." + esac +}} +map xA: unarchive + +cmd tar %{{ + # tars a directory + set -f + printf "gzip? (y,n) " + read answer + case $answer in + y) tar -czf "$f.tar.gz" "$(basename $f)"; rm -rf "$f";; + n) tar -cf "$f.tar" "$(basename $f)"; rm -rf "$f";; + *) printf "\"$answer\" is not a supported answer. Aborting...";; + esac +}} +map xt :tar + +cmd untar %{{ + # untars a directory tar'd with `tar`. + set -f + case $f in + *.tar.gz) tar -xzvf $f; rm "$f";; + *.tar) tar -xvf $f; rm "$f";; + esac +}} +map xT :untar + +cmd zip %{{ + # zip a directory + set -f + zip -r "$f.zip" "$(basename $f)" + rm -rf "$f" +}} +map xz :zip + +cmd unzip %{{ + # unzip a directory + set -f + unzip "$f" + rm "$f" +}} +map xZ :unzip + +# outputs the size of a particular file, dir +# TODO: consider mapping this to a KBD +cmd size %du -hs "$f" +map xs :size diff --git a/configs/shared/.config/lf/marks b/configs/shared/.config/lf/marks new file mode 100644 index 000000000000..aee01d1aa6c3 --- /dev/null +++ b/configs/shared/.config/lf/marks @@ -0,0 +1,7 @@ +':/usr/local/google/home/wpcarro/Dropbox/programming/i3-quickterm +D:~/Dropbox +G:/usr/local/google/home/wpcarro/Downloads +M:/usr/local/google/home/wpcarro/Downloads +c:~/Dropbox/dotfiles/configs +d:~/Dropbox/dotfiles +s:~/Pictures/screenshots diff --git a/configs/shared/.config/mpd/database b/configs/shared/.config/mpd/database new file mode 100644 index 000000000000..b39f769e68e0 Binary files /dev/null and b/configs/shared/.config/mpd/database differ diff --git a/configs/shared/.config/mpd/mpd.conf b/configs/shared/.config/mpd/mpd.conf new file mode 100644 index 000000000000..fbb3858f3d74 --- /dev/null +++ b/configs/shared/.config/mpd/mpd.conf @@ -0,0 +1,4 @@ +db_file "~/.config/mpd/database" +log_file "syslog" +# music_directory "~/.local/share/sounds" +auto_update "yes" \ No newline at end of file diff --git a/configs/shared/.config/nixpkgs/config.nix b/configs/shared/.config/nixpkgs/config.nix new file mode 100644 index 000000000000..1dd1750ae025 --- /dev/null +++ b/configs/shared/.config/nixpkgs/config.nix @@ -0,0 +1,3 @@ +{ + allowUnfree = true; +} diff --git a/configs/shared/.config/nvim/init.vim b/configs/shared/.config/nvim/init.vim new file mode 100644 index 000000000000..eb7dbf3b5313 --- /dev/null +++ b/configs/shared/.config/nvim/init.vim @@ -0,0 +1,669 @@ +" -- BEGIN: Vundle config -- +set nocompatible " be iMproved, required +filetype off " required + +" set the runtime path to include Vundle and initialize +" share Vundle between vim and neovim +set rtp+=~/.vim/bundle/Vundle.vim +set rtp+=~/.config/nvim/bundle/Vundle.vim +call vundle#begin() +" alternatively, pass a path where Vundle should install plugins +"call vundle#begin('~/some/path/here') + +" let Vundle manage Vundle, required +Plugin 'VundleVim/Vundle.vim' + +" Rust IDE features +Plugin 'racer-rust/vim-racer' + +set hidden +let g:racer_experimental_completer = 1 +autocmd FileType rust nmap gd (rust-def) +autocmd FileType rust nmap gs (rust-def-split) +autocmd FileType rust nmap gx (rust-def-vertical) +autocmd FileType rust nmap gd (rust-doc) + +Plugin 'xolox/vim-misc' + +" The following are examples of different formats supported. +" Keep Plugin commands between vundle#begin/end. + +" Displays git information in airline. +Plugin 'tpope/vim-fugitive' + +" easier file navigation +Plugin 'tpope/vim-vinegar' + +" Displays git-tracked C*UD ops within gutter. +Plugin 'airblade/vim-gitgutter' + +" Fuzzy-finder +Plugin 'kien/ctrlp.vim' + +" Grep file contents +Plugin 'mileszs/ack.vim' + +" Syntax and other light-weight suppor for a variety of languages +Plugin 'sheerun/vim-polyglot' + +" Themes +Plugin 'deviantfero/wpgtk.vim' +Plugin 'rainglow/vim' + + +" Executes shell commands and pipes output into new Vim buffer. +Plugin 'sjl/clam.vim' + +" Multiple cursors for simultaneous edits. +" NOTE: use to run miltiple cursors not +Plugin 'terryma/vim-multiple-cursors' + +" Visualize buffers +Plugin 'vim-airline/vim-airline' +Plugin 'vim-airline/vim-airline-themes' + +" Visually align assignments +Plugin 'godlygeek/tabular' + +" Visually Highlight and comment code. +Plugin 'tpope/vim-commentary' + +" Macros for quotes, parens, etc. +Plugin 'tpope/vim-surround' + +" Allows Plugins to be repeated with `.` character +Plugin 'tpope/vim-repeat' + +" Pairs of mappings +Plugin 'tpope/vim-unimpaired' + +" LISPs support +Plugin 'guns/vim-sexp' +Plugin 'tpope/vim-sexp-mappings-for-regular-people' +let g:sexp_enable_insert_mode_mappings = 0 +let g:sexp_filetypes = '' + +" Seamlessly navigate Vim and Tmux with similar bindings. +Plugin 'christoomey/vim-tmux-navigator' + +" Async `:make` for code linting etc. +Plugin 'neomake/neomake' + +" Better buffer mgt than CtrlP +Plugin 'yegappan/mru' + +Plugin 'zanglg/nova.vim' + +" Emulates Emacs's Helm Swoop search +Plugin 'pelodelfuego/vim-swoop' + +" Transparent encryption + decryption +Plugin 'jamessan/vim-gnupg' + +" Javascript auto-formatting +" Plugin 'prettier/vim-prettier', { +" \ 'do': 'yarn install', + " \ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown'] } + +" Support Org mode +Plugin 'jceb/vim-orgmode' + +" Autocompletion +Plugin 'junegunn/fzf' + +" Text objects made easy +Plugin 'kana/vim-textobj-user' + +" Elixir text objects +Plugin 'andyl/vim-textobj-elixir' + +" Making HTML editing faster +Plugin 'mattn/emmet-vim' + +" Snippets for all languages +Plugin 'honza/vim-snippets' + +" Automatic bracket insertion +Plugin 'jiangmiao/auto-pairs' + +" Linting & error warnings +Plugin 'vim-syntastic/syntastic' + +" Angular.js support +Plugin 'burnettk/vim-angular' + +" Asynchronous Linting Engine +Plugin 'w0rp/ale' + +call vundle#end() " required +filetype plugin indent on " required +" Put your non-Plugin stuff after this line +" -- END: Vundle config -- + +" Changes to character. +let mapleader = " " + + +" Highlight column width +set textwidth=80 +set colorcolumn=+0 + +" autoreload a file when it changes on disk +set autoread + +" default to case-insensitive searching +set ignorecase + +" JSX configuration +let g:jsx_ext_required = 0 + + +autocmd FileType reason nnoremap gd :call LanguageClient_textDocument_definition() +autocmd FileType reason nnoremap gf :call LanguageClient_textDocument_formatting() +autocmd FileType reason nnoremap gh :call LanguageClient_textDocument_hover() +autocmd FileType reason nnoremap gr :call LanguageClient_textDocument_rename() + +" Replace with G for faster navigation +nnoremap G +onoremap G +vnoremap G + +" Mirror ZLE KBD +inoremap :echo "Working" + +" Syntastic configuration +set statusline+=%#warningmsg# +set statusline+=%{SyntasticStatuslineFlag()} +set statusline+=%* + +let g:syntastic_always_populate_loc_list = 1 +let g:syntastic_auto_loc_list = 1 +let g:syntastic_check_on_open = 1 +let g:syntastic_check_on_wq = 0 +" let g:syntastic_javascript_checkers = ['eslint'] +let g:syntastic_javascript_eslint_generic = 1 +" this is a hack to prevent a false negative +" https://github.com/vim-syntastic/syntastic/issues/1692 +" let g:syntastic_javascript_eslint_exec = '/bin/ls' +" let g:syntastic_javascript_eslint_exe = 'npx eslint' +" let g:syntastic_javascript_eslint_args = '-f compact' + +" javascript autocompletion +" autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS +" autocmd FileType javascript nnoremap gf :Prettier + +" Maximize the current window +" Similar to Tmux mapping alt-z in my tmux.conf +nnoremap t% :tab sp + +" Allow C-g to act like C-c the way it does in Emacs +cnoremap + +" Prettier configuration +" let g:prettier#exec_cmd_async = 1 +" force Prettier to run on files even without the @format pragma +" let g:prettier#autoformat = 0 + + +" Basic settings +" Thin cursor on INSERT mode +if has('nvim') + let $NVIM_TUI_ENABLE_CURSOR_SHAPE = 1 +endif + +set number +set nowrap +set tabstop=2 +set expandtab +set shiftwidth=2 +set background=dark + +syntax enable +colorscheme peacock + +" Vim in terminal cannot have a different font from the one set within your +" terminal. However, this setting will set the font for the GUI version. +if has('gui_running') + set guifont=Operator\ Mono:h12 +endif + +if has('termguicolors') + set termguicolors +endif + +if &term =~# '^screen' + let &t_8f = "\[38;2;%lu;%lu;%lum" + let &t_8b = "\[48;2;%lu;%lu;%lum" +endif + +set history=1000 +set undolevels=1000 + +set t_Co=255 + +" Support italics +highlight Comment cterm=italic + + +" quickly edit popular configuration files +nnoremap ev :vsplit $MYVIMRC +nnoremap ee :vsplit ~/.emacs.d/init.el +nnoremap ez :vsplit ~/.zshrc +nnoremap ea :vsplit ~/aliases.zsh +nnoremap ef :vsplit ~/functions.zsh +nnoremap el :vsplit ~/variables.zsh +nnoremap ex :vsplit ~/.Xresources +nnoremap ei :vsplit ~/.config/i3/config.shared + +" quickly source your vimrc +nnoremap sv :source $MYVIMRC + +" quickly edit your snippets +nnoremap es :vsplit:edit ~/.vim/bundle/vim-snippets/snippets/reason.snippets + + +" Auto resize window splits +autocmd VimResized * wincmd = + + +" Neomake Settings +autocmd! BufWritePost * Neomake + +" Elixir linting +let g:neomake_elixir_credo_maker = { + \ 'exe': 'mix', + \ 'args': ['credo', 'list', '%:p', '--format=oneline'], + \ 'errorformat': + \ '%W[F] %. %f:%l:%c %m,' . + \ '%W[F] %. %f:%l %m,' . + \ '%W[R] %. %f:%l:%c %m,' . + \ '%W[R] %. %f:%l %m,' . + \ '%I[C] %. %f:%l:%c %m,' . + \ '%I[C] %. %f:%l %m,' . + \ '%-Z%.%#' + \ } + + +let g:neomake_elixir_enabled_makers = ['mix', 'credo'] + +augroup my_error_signs + au! + autocmd ColorScheme * hi NeomakeErrorSign ctermfg=203 guifg=#ff5f5f + autocmd ColorScheme * hi NeomakeWarningSign ctermfg=209 guifg=#ffaf00 + autocmd ColorScheme * hi NeomakeInfoSign ctermfg=183 guifg=#dfafff + autocmd ColorScheme * hi NeomakeMessageSign ctermfg=27 guifg=#0087ff +augroup END + + +" templates +if has("autocmd") + autocmd BufNewFile *.c 0r ~/.config/nvim/templates/boilerplate.c + autocmd BufNewFile *.rs 0r ~/.config/nvim/templates/boilerplate.rs +endif + +let g:neomake_error_sign = { + \ 'text': '>>', + \ 'texthl': 'NeoMakeErrorSign', + \ } + +let g:neomake_warning_sign = { + \ 'text': '>>', + \ 'texthl': 'NeoMakeWarningSign', + \ } + +let g:neomake_info_sign = { + \ 'text': '>>', + \ 'texthl': 'NeoMakeInfoSign', + \ } + +let g:neomake_message_sign = { + \ 'text': '>>', + \ 'texthl': 'NeoMakeMessageSign', + \ } + +function! LocationPrevious() + try + lprev + catch /^Vim\%((\a\+)\)\=:E553/ + llast + endtry +endfunction + +function! LocationNext() + try + lnext + catch /^Vim\%((\a\+)\)\=:E553/ + lfirst + endtry +endfunction + +nnoremap [ :call LocationPrevious() +nnoremap ] :call LocationNext() + + +" Alchemist settings +let g:alchemist#elixir_erlang_src = '/usr/local/share/src' + + +" Airline Settings +" Enables the list of buffers. +let g:airline#extensions#tabline#enabled = 0 + +" Buffer numbers alongside files +let g:airline#extensions#tabline#buffer_nr_show = 0 + +" Shows the filename only. +let g:airline#extensions#tabline#fnamemod = ':t' + +" Allow glyphs in airline +let g:airline_powerline_fonts = 1 + +" Change Airline theme +let g:airline_theme = 'hybrid' + + +" Vim-Swoop Settings +" Edits colorscheme +let g:swoopHighlight = ["hi! link SwoopBufferLineHi Warning", "hi! link SwoopPatternHi Error"] + + +" Jump to buffers. +nmap :1b +nmap :2b +nmap :3b +nmap :4b +nmap :5b +nmap :6b +nmap :7b +nmap :8b +nmap :9b + + +" It's the twenty-first century...no swaps. +set noswapfile + + +" Allow visual tab completion in command mode +set wildmenu + + +" Show Vim commands as they're being input. +set showcmd + + +" Code folding +" set foldmethod=indent +" set foldnestmax=10 +" set nofoldenable +" set foldlevel=4 + + +" emulate ci" and ci' behavior +nnoremap ci( f(%ci( +nnoremap ci[ f[%ci[ + + +" extend functionality of & scrolling +nnoremap j +vnoremap j +nnoremap k +vnoremap k + + +" Opens all folds within the buffer +" nnoremap ZZ zR + +" Closes all folds within the buffer +" nnoremap zz zM + +" Opens all folds beneath the cursor +" NOTE: j is the character to go down +" nnoremap zJ zO + +" Opens single fold beneath the cursor +" NOTE: j is the character to go down +" nnoremap zj zo + +" Opens single fold beneath the cursor +" NOTE: k is the character to go down +" nnoremap zK zC + +" Opens single fold beneath the cursor +" NOTE: k is the character to go down +" nnoremap zk zc + + +" Save shortcut +nnoremap :w + + +" Switch to MRU'd buffer +nnoremap + + +" Alternative MRU to CtrlP MRU +nnoremap b :MRU + + +" Supports mouse interaction. +set mouse=a + + +" Highlights matches during a search. +set hlsearch + +" Clear highlight +noremap h :nohlsearch:echo + + +" backspace settings +set backspace=2 +set backspace=indent,eol,start + + +" Javascript specific variables +let g:javascript_plugin_jsdoc = 1 + +" GlobalListchars +set list +set listchars=tab:··,trail:·,nbsp:· + + +" Keeps everything concealed at all times. Even when cursor is on the word. +set conceallevel=1 +set concealcursor=nvic + + +" map jk to +inoremap jk + + +" Hybrid mode for Vim +inoremap I +inoremap A + +inoremap +inoremap + +inoremap +inoremap +inoremap +inoremap + +" temporarily disable in normal mode so it doesn't attempt to index all of +" Google3. +nnoremap :echo "You are attempting to index all of Google3. Aborting..." + +" tab maintenence +nnoremap :tabnew +nnoremap :tabclose +nnoremap :tabnext +nnoremap :tabprevious + +" Manage Vertical and Horizontal splits +nnoremap sl :vsl +nnoremap sh :vs +nnoremap sj :spj +nnoremap sk :sp + + +" Delete (i.e. "close") the currently opened buffer +" TODO: unless it's a split window, which should be :q +nnoremap q :bdelete + + +" Set CtrlP runtime path +set runtimepath^=~/.vim/bundle/ctrlp.vim + + +" Pane movement +let g:tmux_navigator_no_mappings = 1 + +nnoremap :TmuxNavigateLeft +nnoremap :TmuxNavigateDown +nnoremap :TmuxNavigateUp +nnoremap :TmuxNavigateRight +nnoremap :q + +" make Y do what is intuitive given: +" D: deletes until EOL +" C: changes until EOL +" Y: (should) yank until EOL +nnoremap Y y$ + + +" scrolling and maintaing mouse position +" nnoremap j +" nnoremap k + + +" remap redo key that is eclipsed by `rotate` currently +nnoremap U :redo + + +" Define highlighting groups +" NOTE: The ANSII aliases for colors will change when iTerm2 settings are +" changed. +highlight InterestingWord1 ctermbg=Magenta ctermfg=Black +highlight InterestingWord2 ctermbg=Blue ctermfg=Black + +" h1 highlighting +nnoremap 1 :execute '2match InterestingWord1 /\<\>/' +nnoremap x1 :execute '2match none' +vnoremap 1 :execute '2match InterestingWord1 /\<\>/' + +" h2 highlighting +nnoremap 2 :execute '3match InterestingWord2 /\<\>/' +nnoremap x2 :execute '3match none' + +"clear all highlighted groups +nnoremap xx :execute '2match none' :execute '3match none' hh + + +" pasteboard copy & paste +set clipboard+=unnamedplus + + +" Manage 80 char line limits +highlight OverLength1 ctermbg=Magenta ctermfg=Black +highlight OverLength2 ctermbg=LightMagenta ctermfg=Black +highlight OverLength3 ctermbg=White ctermfg=Black +" match OverLength3 /\%81v.\+/ +match OverLength2 /\%91v.\+/ +" match OverLength3 /\%101v.\+/ + +nnoremap w :w + + +" Resize split to 10,20,...,100 chars +" Uncomment the next lines for support at those sizes. +" These bindings interfere with the highlight groups, however. +" Increases the width of a vertical split. +" nnoremap 1 :vertical resize 10 +" nnoremap 2 :vertical resize 20 +nnoremap 3 :vertical resize 30 +nnoremap 4 :vertical resize 40 +nnoremap 5 :vertical resize 50 +nnoremap 6 :vertical resize 60 +nnoremap 7 :vertical resize 70 +nnoremap 8 :vertical resize 80 +nnoremap 9 :vertical resize 90 +nnoremap 0 :vertical resize 100 + + +" Increases the height of a horizontal split. +nnoremap v1 :resize 5 +nnoremap v2 :resize 10 +nnoremap v3 :resize 15 +nnoremap v4 :resize 20 +nnoremap v5 :resize 25 +nnoremap v6 :resize 30 +nnoremap v7 :resize 35 +nnoremap v8 :resize 40 +nnoremap v9 :resize 45 +nnoremap v0 :resize 50 + + +" BOL and EOL +nnoremap H ^ +vnoremap H ^ +nnoremap L $ +vnoremap L $ + + +" Search for visually selected text +vnoremap // y/"N + + +" trim trailing whitespace on save +" Are there any file type where I wouldn't want this? +autocmd BufWritePre *.{js,py,tpl,less,html,ex,exs,txt,hs,java,rs,ml} :%s/\s\+$//e + + +" Use .gitignore file to populate Ctrl-P +let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f'] + + +" Ignores dirs and files +let g:ctrlp_custom_ignore = { + \ 'dir': 'node_modules', + \ 'file': '\v\.(exe|dll|png|jpg|jpeg)$' +\} + + +" WIP: Run elixir tests on that line +" TODO: only register binding in *.exs? file extensions +nnoremap t :call ExTestToggle() + + +" Jumps from an Elixir module file to an Elixir test file. +fun! ExTestToggle() + if expand('%:e') == "ex" + + let test_file_name = expand('%:t:r') . "_test.exs" + let test_file_dir = substitute(expand('%:p:h'), "/lib/", "/test/", "") + let full_test_path = join([test_file_dir, test_file_name], "/") + + e `=full_test_path` + + elseif match(expand('%:t'), "_test.exs") != -1 + + let test_file_name = expand('%:t:r') + let offset_amt = strlen(test_file_name) - strlen("_test") + let module_file_name = strpart(test_file_name, 0, offset_amt) . ".ex" + let module_file_dir = substitute(expand('%:p:h'), "/test/", "/lib/", "") + let full_module_path = join([module_file_dir, module_file_name], "/") + + e `=full_module_path` + + endif +endfun + + +" Creates intermediate directories and file to match current buffer's filepath +fun! CreateNonExistingDirsAndFile() + ! echo "Creating directory..." && mkdir -p %:p:h && echo "Created directory." && echo "Creating file..." && touch %:t:p && echo "Created file." + + " Write the buffer to the recently created file. + w +endfun diff --git a/configs/shared/.config/nvim/simple.vim b/configs/shared/.config/nvim/simple.vim new file mode 100644 index 000000000000..ea40964ee803 --- /dev/null +++ b/configs/shared/.config/nvim/simple.vim @@ -0,0 +1,98 @@ +" My barebones vimrc without any Vundle dependencies. +" +" I'm attempting to optimize the following: +" - Minimize dependencies +" - Maximize ergonomics +" - Maximize Tmux compatibility +" - Minimize shadowing of existing Vim KBDs +" +" Warning: This is currently unstable as it is a work-in-progress. +" +" Author: William Carroll + +" Use as the leader key. +let mapleader = " " +nnoremap ev :tabnew:edit ~/.vimrc +nnoremap sv :source ~/.vimrc +nnoremap w :w +nnoremap h :help + +" increment,decrement numbers +nnoremap + +" TODO: Restore with better KBD +" nnoremap - + +" Visit the CWD +nnoremap - :e . + +" Turn line numbers on. +set number + +" Easily create vertical, horizontal window splits. +nnoremap sh :vsplit +nnoremap sj :split:wincmd j +nnoremap sk :split +nnoremap sl :vsplit:wincmd l + +" Move across window splits. +" TODO: Change to . +nnoremap :wincmd h +nnoremap :wincmd j +nnoremap :wincmd k +nnoremap :wincmd l + +" TODO: Support these. +" nnoremap :q +" nnoremap :wincmd h +" nnoremap :wincmd j +" nnoremap :wincmd k +" nnoremap :wincmd l + +" Use instead of G to support: +" 20 - to jump to line 20 +" d20 - to delete from the current line until line 20 +" 20 - to select from the current line until line 20 +nnoremap G +onoremap G +vnoremap G + +" Easily change modes on keyboards that don't have CapsLock mapped to +inoremap jk + +" CRUD tabs. +nnoremap :tabnext +nnoremap :tabprevious +nnoremap :tabnew:edit . +nnoremap :tabclose +" TODO: Re-enable these once are supported. +" nnoremap :+tabmove +" nnoremap :-tabmove + +" Use H,L to goto beggining,end of a line. +" Swaps the keys to ensure original functionality of H,L are preserved. +nnoremap H ^ +nnoremap L $ +nnoremap ^ H +nnoremap $ L + +" Use H,L in visual mode too +vnoremap H ^ +vnoremap L $ +vnoremap ^ H +vnoremap $ L + +" Emacs hybrid mode +" TODO: model this after tpope's rsi.vim (Readline-style insertion) +cnoremap +cnoremap +inoremap ^ +inoremap $ +inoremap h +inoremap l + +" Indenting +" The following three settings are based on option 2 of `:help tabstop` +set tabstop=4 +set shiftwidth=4 +set expandtab +set autoindent diff --git a/configs/shared/.config/nvim/templates/boilerplate.c b/configs/shared/.config/nvim/templates/boilerplate.c new file mode 100644 index 000000000000..949743d72587 --- /dev/null +++ b/configs/shared/.config/nvim/templates/boilerplate.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello, world!"); + return 0; +} diff --git a/configs/shared/.config/nvim/templates/boilerplate.rs b/configs/shared/.config/nvim/templates/boilerplate.rs new file mode 100644 index 000000000000..c83adbc69fa0 --- /dev/null +++ b/configs/shared/.config/nvim/templates/boilerplate.rs @@ -0,0 +1,5 @@ +fn main() { + // The statements here will be executed when the compiled binary is called. + + println!("Hello, world!"); +} diff --git a/configs/shared/.config/rofi/config b/configs/shared/.config/rofi/config new file mode 100644 index 000000000000..576ab5cd8e68 --- /dev/null +++ b/configs/shared/.config/rofi/config @@ -0,0 +1,6 @@ +rofi.font: Monospace 10 +rofi.color-normal: #31213f, #8de0e1, #31213f, #83526a, #8de0e1 +rofi.color-urgent: #31213f, #d6b48d, #22231D, #d6b48d, #8de0e1 +rofi.color-active: #31213f, #3CC2B5, #31213f, #3CC2B5, #31213f +rofi.color-window: #31213f, #83526a, #5a3849 +rofi.modi: window,run,ssh,combi diff --git a/configs/shared/.config/rofi/config.bak b/configs/shared/.config/rofi/config.bak new file mode 100644 index 000000000000..cd77833442f4 --- /dev/null +++ b/configs/shared/.config/rofi/config.bak @@ -0,0 +1,6 @@ +rofi.font: Source Code Pro 10 +rofi.color-normal: #01022E, #a7dff4, #01022E, #015f9e, #a7dff4 +rofi.color-urgent: #01022E, #d6b48d, #22231D, #d6b48d, #a7dff4 +rofi.color-active: #01022E, #3FA4E0, #01022E, #3FA4E0, #01022E +rofi.color-window: #01022E, #015f9e, #01416c +rofi.modi: window,run,ssh,combi diff --git a/configs/shared/.config/systemd/user/clipmenud.service b/configs/shared/.config/systemd/user/clipmenud.service new file mode 100644 index 000000000000..fac317f3f072 --- /dev/null +++ b/configs/shared/.config/systemd/user/clipmenud.service @@ -0,0 +1,18 @@ +[Unit] +Description=Clipmenu daemon + +[Service] +ExecStart=clipmenud +Restart=always +RestartSec=500ms +Environment=DISPLAY=:0 + +MemoryDenyWriteExecute=yes +NoNewPrivileges=yes +ProtectControlGroups=yes +ProtectKernelTunables=yes +RestrictAddressFamilies= +RestrictRealtime=yes + +[Install] +WantedBy=default.target diff --git a/configs/shared/.config/systemd/user/default.target.wants/clipmenud.service b/configs/shared/.config/systemd/user/default.target.wants/clipmenud.service new file mode 120000 index 000000000000..387f2023d2d2 --- /dev/null +++ b/configs/shared/.config/systemd/user/default.target.wants/clipmenud.service @@ -0,0 +1 @@ +/usr/local/google/home/wpcarro/.config/systemd/user/clipmenud.service \ No newline at end of file diff --git a/configs/shared/.config/terminator/config b/configs/shared/.config/terminator/config new file mode 100644 index 000000000000..9357a7ed29f9 --- /dev/null +++ b/configs/shared/.config/terminator/config @@ -0,0 +1,34 @@ +[global_config] + enabled_plugins = LaunchpadBugURLHandler, LaunchpadCodeURLHandler, APTURLHandler, TerminatorThemes +[keybindings] +[profiles] + [[default]] + background_color = "#ffffff" + cursor_shape = ibeam + cursor_color = "#E29B61" + font = Input Mono Medium 12 + foreground_color = "#000000" + show_titlebar = False + scrollbar_position = hidden + palette = "#31213f:#e29b61:#e8c35f:#565b87:#a56785:#20a89e:#3cc2b5:#8de0e1:#629c9d:#e29b61:#e8c35f:#565b87:#a56785:#20a89e:#3cc2b5:#8de0e1" + use_system_font = False + [[Molokai]] + background_color = "#121212" + cursor_shape = ibeam + cursor_color = "#bbbbbb" + font = Input Mono Medium 12 + foreground_color = "#bbbbbb" + show_titlebar = False + scrollbar_position = hidden + palette = "#121212:#fa2573:#98e123:#dfd460:#1080d0:#8700ff:#43a8d0:#bbbbbb:#555555:#f6669d:#b1e05f:#fff26d:#00afff:#af87ff:#51ceff:#ffffff" + use_system_font = False +[layouts] + [[default]] + [[[child1]]] + parent = window0 + type = Terminal + profile = Molokai + [[[window0]]] + parent = "" + type = Window +[plugins] diff --git a/configs/shared/.config/terminator/config.bak b/configs/shared/.config/terminator/config.bak new file mode 100644 index 000000000000..d25a89c99e60 --- /dev/null +++ b/configs/shared/.config/terminator/config.bak @@ -0,0 +1,23 @@ +[global_config] + enabled_plugins = LaunchpadBugURLHandler, LaunchpadCodeURLHandler, APTURLHandler +[keybindings] +[profiles] + [[default]] + background_color = "#01022E" + cursor_shape = ibeam + cursor_color = "#434AA6" + font = Source Code Pro 10 + foreground_color = "#0278C6" + show_titlebar = False + scrollbar_position = hidden + palette = "#01022E:#434AA6:#0278C6:#9B6DB0:#018CD5:#07AAE9:#3FA4E0:#a7dff4:#749caa:#434AA6:#0278C6:#9B6DB0:#018CD5:#07AAE9:#3FA4E0:#a7dff4" + use_system_font = False +[layouts] + [[default]] + [[[child1]]] + parent = window0 + type = Terminal + [[[window0]]] + parent = "" + type = Window +[plugins] diff --git a/configs/shared/.config/terminator/plugins/terminator-themes.py b/configs/shared/.config/terminator/plugins/terminator-themes.py new file mode 100644 index 000000000000..fa807c65bd2a --- /dev/null +++ b/configs/shared/.config/terminator/plugins/terminator-themes.py @@ -0,0 +1,250 @@ +import requests +import terminatorlib.plugin as plugin +from gi.repository import Gtk +from terminatorlib.config import ConfigBase +from terminatorlib.translation import _ +from terminatorlib.util import get_config_dir, err, dbg, gerr + +AVAILABLE = ['TerminatorThemes'] + +class TerminatorThemes(plugin.Plugin): + + capabilities = ['terminal_menu'] + config_base = ConfigBase() + base_url = 'https://api.github.com/repos/EliverLara/terminator-themes/contents/themes.json' + inherits_config_from = "default" + + def callback(self, menuitems, menu, terminal): + """Add our item to the menu""" + self.terminal = terminal + item = Gtk.ImageMenuItem(Gtk.STOCK_FIND) + item.connect('activate',self.configure) + item.set_label("Themes") + item.set_sensitive(True) + menuitems.append(item) + + def configure(self, widget, data = None): + ui = {} + dbox = Gtk.Dialog( _("Terminator themes"), None, Gtk.DialogFlags.MODAL) + + headers = { "Accept": "application/vnd.github.v3.raw" } + response = requests.get(self.base_url, headers=headers) + + if response.status_code != 200: + gerr(_("Failed to get list of available themes")) + return + + self.themes_from_repo = response.json()["themes"] + self.profiles = self.terminal.config.list_profiles() + + main_container = Gtk.HBox(spacing=5) + main_container.pack_start(self._create_themes_grid(ui), True, True, 0) + main_container.pack_start(self._create_settings_grid(ui), True, True, 0) + dbox.vbox.pack_start(main_container, True, True, 0) + + self.dbox = dbox + dbox.show_all() + res = dbox.run() + + if res == Gtk.ResponseType.ACCEPT: + self.terminal.config.save() + + del(self.dbox) + dbox.destroy() + + return + + def _create_themes_grid(self, ui): + grid = Gtk.Grid() + grid.set_column_spacing(5) + grid.set_row_spacing(7) + grid.set_column_homogeneous(True) + grid.set_row_homogeneous(True) + + scroll_window = self._create_themes_list(ui) + + #creating buttons to filter by theme type, and setting up their events + buttons = list() + for theme_type in ["light", "dark", "None"]: + button = Gtk.Button(theme_type) + buttons.append(button) + button.connect("clicked", self.on_filter_button_clicked) + + grid.attach(scroll_window, 0, 0, 4, 10) + grid.attach_next_to(buttons[0], scroll_window, Gtk.PositionType.BOTTOM, 1, 1) + + for i, button in enumerate(buttons[1:]): + grid.attach_next_to(button, buttons[i], Gtk.PositionType.RIGHT, 1, 1) + + return grid + + def _create_themes_list(self, ui): + + profiles_list_model = Gtk.ListStore(str, str,bool, object) + # Set add/remove buttons availability + for theme in self.themes_from_repo: + if theme["name"] in self.profiles: + profiles_list_model.append([theme["name"], theme["type"],False, theme]) + else: + profiles_list_model.append([theme["name"], theme["type"],True, theme]) + + self.current_filter_theme = None + self.theme_filter = profiles_list_model.filter_new() + self.theme_filter.set_visible_func(self.theme_filter_func) + + treeview = Gtk.TreeView.new_with_model(self.theme_filter) + + selection = treeview.get_selection() + selection.set_mode(Gtk.SelectionMode.SINGLE) + selection.connect("changed", self.on_selection_changed, ui) + ui['treeview'] = treeview + + for i, column_title in enumerate(["Theme", "Type"]): + renderer = Gtk.CellRendererText() + column = Gtk.TreeViewColumn(column_title, renderer, text=i) + treeview.append_column(column) + + scroll_window = Gtk.ScrolledWindow() + scroll_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) + scroll_window.add(treeview) + + return scroll_window + + + def _create_settings_grid(self, ui): + grid = Gtk.Grid() + grid.set_column_spacing(5) + grid.set_row_spacing(7) + grid.attach(self._create_default_inherits_check(ui), 0, 0, 2, 1) + grid.attach(Gtk.Label("Available profiles: "), 0, 1, 1, 1) + grid.attach(self._create_inherits_from_combo(ui), 1, 1, 1, 1) + grid.attach(self._create_main_action_button(ui, "install", self.on_install), 0, 4, 1, 1) + grid.attach(self._create_main_action_button(ui, "remove", self.on_uninstall), 1, 4, 1, 1) + + return grid + + def _create_default_inherits_check(self, ui): + check = Gtk.CheckButton("Inherit preferences from default profile") + check.set_active(True) + check.connect("toggled", self.on_inheritsfromdefaultcheck_toggled, ui) + ui['check_inherits_from_default'] = check + + return check + + def _create_inherits_from_combo(self, ui): + combo = Gtk.ComboBoxText() + combo.set_entry_text_column(0) + combo.set_sensitive(False) + combo.connect("changed", self.on_inheritsfromcombo_changed, ui) + ui['inherits_from_combo'] = combo + + for profile in self.profiles: + combo.append_text(profile) + + combo.set_active(self.profiles.index(self.terminal.config.get_profile())) + + return combo + + def _create_main_action_button(self, ui, label, action): + btn = Gtk.Button(_(label.capitalize())) + btn.connect("clicked", action, ui) + btn.set_sensitive(False) + ui['button_' + label] = btn + + return btn + + def theme_filter_func(self, model, iter, data): + """Tests if the theme in the row is the one in the filter""" + if self.current_filter_theme is None or self.current_filter_theme == "None": + return True + else: + return model[iter][1] == self.current_filter_theme + + def on_filter_button_clicked(self, widget): + """Called on any of the button clicks""" + #we set the current theme filter to the button's label + self.current_filter_theme = widget.get_label() + + #we update the filter, which updates in turn the view + self.theme_filter.refilter() + + + def on_inheritsfromdefaultcheck_toggled(self, check, data=None): + if check.get_active() is not True: + data["inherits_from_combo"].set_sensitive(True) + self.inherits_config_from = self.profiles[data['inherits_from_combo'].get_active()] + else: + data["inherits_from_combo"].set_sensitive(False) + self.inherits_config_from = 'default' + + def on_inheritsfromcombo_changed(self, combo, data): + if combo.get_sensitive(): + self.inherits_config_from = self.profiles[combo.get_active()] + else: + self.inherits_config_from = 'default' + + def on_selection_changed(self, selection, data=None): + (model, iter) = selection.get_selected() + data['button_install'].set_sensitive(model[iter][2]) + data['button_remove'].set_sensitive(model[iter][2] is not True) + + def on_uninstall(self, button, data): + treeview = data['treeview'] + selection = treeview.get_selection() + (store, iter) = selection.get_selected() + target = store[iter][0] + + # If selected theme is active, sets terminal profile to default before unistalling + if self.terminal.get_profile() == target: + widget = self.terminal.get_vte() + self.terminal.force_set_profile(widget, 'default') + + self.terminal.config.del_profile(target) + self.terminal.config.save() + self.update_comboInheritsFrom(data) + + #'Add' button available again + data['treeview'].get_model().set_value(iter, 2, True) + self.on_selection_changed(selection, data) + + def on_install(self, button, data): + treeview = data['treeview'] + selection = treeview.get_selection() + (store, iter) = selection.get_selected() + target = store[iter][3] + widget = self.terminal.get_vte() + treeview.set_enable_tree_lines(False) + + if not iter: + return + + self.terminal.config.add_profile(target["name"]) + template_data = self.config_base.profiles[self.inherits_config_from].copy() + + for k, v in target.items(): + if k != 'background_image' and k != 'name' and k != 'type': + if k == 'background_darkness': + template_data[k] = float(v) + else: + template_data[k] = v + + for k, v in template_data.items(): + self.config_base.set_item(k, v, target["name"]) + + self.terminal.force_set_profile(widget, target["name"]) + self.terminal.config.save() + self.update_comboInheritsFrom(data) + + # "Remove" button available again + data['treeview'].get_model().set_value(iter, 2, False) + self.on_selection_changed(selection, data) + treeview.set_enable_tree_lines(True) + + def update_comboInheritsFrom(self, data): + data['inherits_from_combo'].remove_all() + profiles = self.terminal.config.list_profiles() + self.profiles = profiles + for profile in profiles: + data['inherits_from_combo'].append_text(profile) + + data['inherits_from_combo'].set_active(profiles.index(self.terminal.config.get_profile())) \ No newline at end of file -- cgit 1.4.1