dotfiles

commit 943b3ebe9a60a749bcf8ab314289b34117f6ba5f

Author: Honza Pokorny <me@honza.ca>

Separate sway and i3

 i3/config | 23 ----
 sway/config | 198 ++++++++++++++++++++++++++++++++++++++++++++++++
 sway/i3status.conf | 63 +++++++++++++++
 sway/i3status.py | 126 ++++++++++++++++++++++++++++++


diff --git a/i3/config b/i3/config
index 6249ec7829332f99f134ba9f36629ad4a2246fb3..490c34e5dacf8470a6fc78886b4f4a93dd448e95 100644
--- a/i3/config
+++ b/i3/config
@@ -146,8 +146,8 @@ # Start i3bar to display a workspace bar (plus the system information i3status
 # finds out, if available)
 bar {
         position top
-        swaybar_command waybar
-        # status_command i3status -c ~/.i3/i3status.conf | ~/.i3/i3status.py
+        # swaybar_command waybar
+        status_command i3status -c ~/.i3/i3status.conf | ~/.i3/i3status.py
         # status_command ~/bin/i3status-rs ~/dotfiles/i3/i3bar.toml
         font pango:Monoid 8
 
@@ -177,22 +177,7 @@ # you can use nmcli instead
 # exec nm-applet
 
 # keyboard doesn't work with wayland because it contains x11-specific settings
-# exec keyboard
+exec keyboard
 
 # mako gives you notifications (it's a dunst replacement)
-exec_always  mako
-
-# For the built-in laptop keyboard, turn capslock into ctrl
-input 1:1:AT_Translated_Set_2_keyboard {
-
-  # ------ WARNING ------
-  # Do not set this to "cs", it's a Russian keyboard
-  # Use "cz" for the Czech keyboard
-  #
-  xkb_layout us
-  xkb_options ctrl:nocaps
-}
-
-exec_always swayidle -w \
-    timeout 600 'swaymsg "output * dpms off"' \
-    resume 'swaymsg "output * dpms on"'
+exec_always dunst




diff --git a/sway/config b/sway/config
new file mode 100644
index 0000000000000000000000000000000000000000..5fe98d3d5a44eac5afe6b656a5b1c9c17f10cae4
--- /dev/null
+++ b/sway/config
@@ -0,0 +1,198 @@
+set $mod Mod4
+set $hyper Mod4+Control+Shift+Mod1
+set $term --no-startup-id gnome-terminal
+
+# Font for window titles. Will also be used by the bar unless a different font
+# is used in the bar {} block below. ISO 10646 = Unicode
+# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+font pango:Monoid 8
+
+# Use Mouse+$mod to drag floating windows to their wanted position
+floating_modifier $mod
+
+# start a terminal
+bindsym $mod+Return exec $term
+
+# Open a new tab of an existing firefox instance
+bindsym $mod+Shift+Delete exec firefox
+
+bindsym $mod+Mod1+Return exec nautilus
+
+bindsym $mod+n workspace next
+bindsym $mod+Shift+n workspace prev
+
+bindsym $mod+b workspace back_and_forth
+
+# kill focused window
+bindsym $mod+q kill
+
+# start dmenu (a program launcher)
+bindsym $mod+d exec rofi -show run
+
+# There also is the (new) i3-dmenu-desktop which only displays applications
+# shipping a .desktop file. It is a wrapper around dmenu, so you need that
+# installed.
+# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
+bindsym $mod+Shift+d exec --no-startup-id i3-dmenu-desktop
+bindsym $mod+Shift+l exec --no-startup-id swaylock -c 000000 -f
+
+# alternatively, you can use the cursor keys:
+bindsym $mod+h focus left
+bindsym $mod+j focus down
+bindsym $mod+k focus up
+bindsym $mod+l focus right
+
+# split in horizontal orientation
+bindsym $mod+Shift+h split h
+
+# split in vertical orientation
+bindsym $mod+v split v
+
+# enter fullscreen mode for the focused container
+bindsym $mod+f fullscreen
+
+# change container layout (stacked, tabbed, toggle split)
+bindsym $mod+s layout stacking
+bindsym $mod+w layout tabbed
+bindsym $mod+e layout toggle split
+
+# toggle tiling / floating
+bindsym $mod+Shift+space floating toggle
+
+bindsym $mod+space exec "emacsclient -nc"
+
+# focus the parent container
+bindsym $mod+a focus parent
+
+# focus the child container
+#bindsym $mod+d focus child
+
+# switch to workspace
+bindsym $mod+1 workspace number 1
+bindsym $mod+2 workspace number 2
+bindsym $mod+3 workspace number 3
+bindsym $mod+4 workspace number 4
+bindsym $mod+5 workspace number 5
+bindsym $mod+6 workspace number 6
+bindsym $mod+7 workspace number 7
+bindsym $mod+8 workspace number 8
+bindsym $mod+9 workspace number 9
+bindsym $mod+0 workspace number 10
+
+
+# hyper + right hand numpad on the ergodox
+bindsym $hyper+m workspace number 1
+bindsym $hyper+w workspace number 2
+bindsym $hyper+v workspace number 3
+bindsym $hyper+h workspace number 4
+bindsym $hyper+t workspace number 5
+bindsym $hyper+n workspace number 6
+bindsym $hyper+g workspace number 7
+bindsym $hyper+c workspace number 8
+bindsym $hyper+r workspace number 9
+bindsym $hyper+l workspace number 10
+
+bindsym $hyper+d focus left
+bindsym $hyper+s focus right
+
+# move focused container to workspace
+bindsym $mod+Shift+1 move container to workspace number 1
+bindsym $mod+Shift+2 move container to workspace number 2
+bindsym $mod+Shift+3 move container to workspace number 3
+bindsym $mod+Shift+4 move container to workspace number 4
+bindsym $mod+Shift+5 move container to workspace number 5
+bindsym $mod+Shift+6 move container to workspace number 6
+bindsym $mod+Shift+7 move container to workspace number 7
+bindsym $mod+Shift+8 move container to workspace number 8
+bindsym $mod+Shift+9 move container to workspace number 9
+bindsym $mod+Shift+0 move container to workspace number 10
+
+# reload the configuration file
+bindsym $mod+Shift+c reload
+# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
+bindsym $mod+Shift+r reload
+# exit i3 (logs you out of your X session)
+bindsym $mod+Shift+e 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'"
+
+bindsym $mod+o move workspace to output left
+bindsym $mod+p move workspace to output right
+
+mode "resize" {
+        # These bindings trigger as soon as you enter the resize mode
+
+        bindsym j resize shrink width 5 px or 5 ppt
+        bindsym k resize grow height 5 px or 5 ppt
+        bindsym l resize shrink height 5 px or 5 ppt
+        bindsym semicolon resize grow width 5 px or 5 ppt
+
+        # back to normal: Enter or Escape
+        bindsym Return mode "default"
+        bindsym Escape mode "default"
+}
+
+# class                 border  backgr. text    indicator child_border
+client.focused          #333333 #333333 #ffffff #2e9ef4   #285577
+default_border none
+
+
+bindsym $mod+r mode "resize"
+
+bindsym $mod+i exec $term -e htop
+
+bindsym Print exec gnome-screenshot
+bindsym $hyper+u exec ~/dotfiles/bin/take-screenshot
+
+# Start i3bar to display a workspace bar (plus the system information i3status
+# finds out, if available)
+bar {
+        position top
+        # swaybar_command waybar
+        status_command i3status -c ~/.i3/i3status.conf | ~/.i3/i3status.py
+        # status_command ~/bin/i3status-rs ~/dotfiles/i3/i3bar.toml
+        font pango:Monoid 8
+
+        # Explicitly disable the icon tray (network, dropbox, etc) because it
+        # doesn't work with old icons yet, and just displays a red sad face
+        tray_output none
+}
+
+bindsym XF86AudioRaiseVolume exec amixer -q set Master 5%+ unmute
+bindsym XF86AudioLowerVolume exec amixer -q set Master 5%- unmute
+bindsym Shift+XF86AudioRaiseVolume exec pactl set-sink-volume 0 150%
+bindsym Shift+XF86AudioLowerVolume exec pactl set-sink-volume 0 50%
+bindsym XF86AudioMute exec amixer -q set Master toggle
+
+bindsym XF86MonBrightnessUp exec /bin/brightnessctl set +10%
+bindsym XF86MonBrightnessDown exec /bin/brightnessctl set 10%-
+
+focus_follows_mouse no
+
+# In order for dropbox to work two things need to be installed:
+#   1.  The ~/.dropbox-dist directory
+#   2.  The dropbox.py script from the dropbox website
+exec dropbox 'start'
+
+# applets are useless because swaybar doesn't support old icons
+# you can use nmcli instead
+# exec nm-applet
+
+# keyboard doesn't work with wayland because it contains x11-specific settings
+# exec keyboard
+
+# mako gives you notifications (it's a dunst replacement)
+exec_always  mako
+
+# For the built-in laptop keyboard, turn capslock into ctrl
+input 1:1:AT_Translated_Set_2_keyboard {
+
+  # ------ WARNING ------
+  # Do not set this to "cs", it's a Russian keyboard
+  # Use "cz" for the Czech keyboard
+  #
+  xkb_layout us
+  xkb_options ctrl:nocaps
+}
+
+exec_always swayidle -w \
+    timeout 600 'swaymsg "output * dpms off"' \
+    resume 'swaymsg "output * dpms on"'




diff --git a/sway/i3status.conf b/sway/i3status.conf
new file mode 100644
index 0000000000000000000000000000000000000000..e6bc9555c25047e3f1adc9aa0519cccd55b99f67
--- /dev/null
+++ b/sway/i3status.conf
@@ -0,0 +1,63 @@
+general {
+        colors = true
+        interval = 1
+        output_format = "i3bar"
+        color_good = '#2aa198'
+        color_bad = '#dc322f'
+
+}
+
+order += "ethernet enp12s0u1"
+order += "wireless wlp2s0"
+order += "volume master"
+order += "cpu_usage"
+order += "disk /home/"
+order += "tztime utc"
+order += "tztime local"
+
+# Ethernet via dongle
+ethernet enp0s31f6 {
+        format_up = "E: %ip"
+        format_down = "E: down"
+}
+
+# Ethernet via docking station
+ethernet enp12s0u1 {
+        format_up = "E: %ip"
+        format_down = "E: down"
+}
+
+wireless wlp2s0 {
+        format_up = "W: %ip"
+        format_down = "W: down"
+}
+
+volume master {
+        format = "♪: %volume"
+        device = "default"
+        mixer = "Master"
+        mixer_idx = 0
+}
+
+battery 0 {
+        format = "%status %percentage %remaining"
+        path = "/sys/class/power_supply/BAT%d/uevent"
+        low_threshold = 10
+}
+
+cpu_usage {
+        format = "CPU: %usage"
+}
+
+disk "/home/" {
+        format = "%free"
+}
+
+tztime utc {
+        format = "UTC: %H:%M"
+        timezone = "UTC/UTC"
+}
+
+tztime local {
+        format = "%A %Y-%m-%d %H:%M"
+}




diff --git a/sway/i3status.py b/sway/i3status.py
new file mode 100755
index 0000000000000000000000000000000000000000..814afaf02a99e187910f9d5c46ccd8d20252c8dc
--- /dev/null
+++ b/sway/i3status.py
@@ -0,0 +1,126 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import json
+import os
+import subprocess
+import sys
+
+RED = '#dc322f'
+GREEN = '#2aa198'
+
+NULL = open(os.devnull, 'w')
+
+
+def get_memory():
+
+    try:
+        import psutil
+        val = psutil.virtual_memory().percent
+        if val > 80:
+            color = '#FF0000'
+        else:
+            color = '#FFFFFF'
+        text = "MEM: {0}%".format(val)
+    except ImportError:
+        text = "Failed to load psutil"
+        color = '#FF0000'
+
+    return {
+        'full_text': str(text),
+        'name': 'vpn',
+        'color': color,
+    }
+
+
+def get_vpn():
+    try:
+        subprocess.check_call(
+            ["/home/honza/dotfiles/bin/is-vpn-connected"],
+            stdout=NULL
+        )
+        vpn_connected = True
+    except Exception:
+        vpn_connected = False
+    return {
+        'full_text': "VPN",
+        'name': 'vpn',
+        'color': GREEN if vpn_connected else RED
+    }
+
+
+def get_battery():
+    battery_path = '/sys/class/power_supply/BAT0/uevent'
+    battery_level = 0
+    battery_status = ''
+    battery_critical = False
+
+    f = open(battery_path)
+    battery_data = f.readlines()
+    f.close()
+
+    for line in battery_data:
+        label, value = line.split('=')
+        value = value.replace('\n', '')
+
+        if label == 'POWER_SUPPLY_CAPACITY':
+            battery_level = int(value)
+
+        if label == 'POWER_SUPPLY_STATUS':
+            battery_status = value
+
+    if battery_level < 15:
+        battery_critical = True
+
+    if battery_status == 'Discharging':
+        battery_status = '(bat)'
+    else:
+        battery_status = '(ac)'
+
+    text = 'B: {}% {}'.format(battery_level, battery_status)
+
+    return {
+        'full_text': text,
+        'name': 'bat',
+        'color': '#FF0000' if battery_critical else '#FFFFFF',
+    }
+
+
+def print_line(message):
+    sys.stdout.write(message + '\n')
+    sys.stdout.flush()
+
+
+def read_line():
+    try:
+        line = sys.stdin.readline().strip()
+        if not line:
+            sys.exit(3)
+        return line
+    except KeyboardInterrupt:
+        sys.exit()
+
+
+def main():
+    # The first line is just a Header, with the version
+    print_line(read_line())
+
+    # Then the second line is just "[" as it starts the infinate array. wat
+    print_line(read_line())
+
+    while True:
+        line, prefix = read_line(), ''
+        if line.startswith(','):
+            line, prefix = line[1:], ','
+
+        j = json.loads(line)
+
+        j.insert(0, get_vpn())
+        j.insert(5, get_memory())
+        j.insert(5, get_battery())
+
+        print_line(prefix+json.dumps(j))
+
+
+if __name__ == '__main__':
+    main()