From 89840581fbcc9228f99ca6c448a29d1cd5da2627 Mon Sep 17 00:00:00 2001
From: Amin Bandali <bandali@kelar.org>
Date: Sun, 25 Feb 2024 14:02:36 -0500
Subject: Port my i3 config to sway

---
 .config/sway/config    | 339 +++++++++++++++++++++----------------------------
 .config/sway/nostalgia |  14 ++
 .local/bin/b-ws-util   |   6 +-
 .local/bin/my-bar      |  20 +++
 .local/bin/passmenu    |   4 +-
 5 files changed, 185 insertions(+), 198 deletions(-)
 create mode 100644 .config/sway/nostalgia
 create mode 100755 .local/bin/my-bar

diff --git a/.config/sway/config b/.config/sway/config
index 196b3e7..a077c5b 100644
--- a/.config/sway/config
+++ b/.config/sway/config
@@ -1,219 +1,172 @@
-# Default config for sway
-#
-# Copy this to ~/.config/sway/config and edit it to your liking.
-#
-# Read `man 5 sway` for a complete reference.
-
-### Variables
-#
-# Logo key. Use Mod1 for Alt.
+set $font Source Code Pro Medium 10.5
+font pango:$font
+
+# super
 set $mod Mod4
-# Home row direction keys, like vim
+# alt
+set $mod2 Mod1
+# hyper
+# set $mod3 Mod3
+
 set $left h
 set $down j
 set $up k
 set $right l
-# Your preferred terminal emulator
+
 set $term foot
-# Your preferred application launcher
-# Note: pass the final command to swaymsg so that the resulting window can be opened
-# on the original workspace that the command was run on.
-set $menu dmenu_path | wmenu | xargs swaymsg exec --
-
-include /etc/sway/config-vars.d/*
-
-### Output configuration
-#
-# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)
-output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
-#
-# Example configuration:
-#
-#   output HDMI-A-1 resolution 1920x1080 position 1920,0
-#
-# You can get the names of your outputs by running: swaymsg -t get_outputs
-
-### Idle configuration
-#
-# Example configuration:
-#
-# exec swayidle -w \
-#          timeout 300 'swaylock -f -c 000000' \
-#          timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
-#          before-sleep 'swaylock -f -c 000000'
-#
-# This will lock your screen after 300 seconds of inactivity, then turn off
-# your displays after another 300 seconds, and turn your screens back on when
-# resumed. It will also lock your screen before your computer goes to sleep.
-
-### Input configuration
-#
-# Example configuration:
-#
-#   input "2:14:SynPS/2_Synaptics_TouchPad" {
-#       dwt enabled
-#       tap enabled
-#       natural_scroll enabled
-#       middle_emulation enabled
-#   }
-#
-# You can get the names of your inputs by running: swaymsg -t get_inputs
-# Read `man 5 sway-input` for more information about this section.
-
-### Key bindings
-#
-# Basics:
-#
-    # Start a terminal
-    bindsym $mod+Return exec $term
-
-    # Kill focused window
-    bindsym $mod+Shift+q kill
-
-    # Start your launcher
-    bindsym $mod+d exec $menu
-
-    # Drag floating windows by holding down $mod and left mouse button.
-    # Resize them with right mouse button + $mod.
-    # Despite the name, also works for non-floating windows.
-    # Change normal to inverse to use left mouse button for resizing and right
-    # mouse button for dragging.
-    floating_modifier $mod normal
-
-    # Reload the configuration file
-    bindsym $mod+Shift+c reload
-
-    # Exit sway (logs you out of your Wayland session)
-    bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit'
-#
-# Moving around:
-#
-    # Move your focus around
-    bindsym $mod+$left focus left
-    bindsym $mod+$down focus down
-    bindsym $mod+$up focus up
-    bindsym $mod+$right focus right
-    # Or use $mod+[up|down|left|right]
-    bindsym $mod+Left focus left
-    bindsym $mod+Down focus down
-    bindsym $mod+Up focus up
-    bindsym $mod+Right focus right
-
-    # Move the focused window with the same, but add Shift
-    bindsym $mod+Shift+$left move left
-    bindsym $mod+Shift+$down move down
-    bindsym $mod+Shift+$up move up
-    bindsym $mod+Shift+$right move right
-    # Ditto, with arrow keys
-    bindsym $mod+Shift+Left move left
-    bindsym $mod+Shift+Down move down
-    bindsym $mod+Shift+Up move up
-    bindsym $mod+Shift+Right move right
-#
-# Workspaces:
-#
-    # 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
-    # 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
-    # Note: workspaces can have any name you want, not just numbers.
-    # We just use 1-10 as the default.
-#
-# Layout stuff:
-#
-    # You can "split" the current object of your focus with
-    # $mod+b or $mod+v, for horizontal and vertical splits
-    # respectively.
-    bindsym $mod+b splith
-    bindsym $mod+v splitv
-
-    # Switch the current container between different layout styles
-    bindsym $mod+s layout stacking
-    bindsym $mod+w layout tabbed
-    bindsym $mod+e layout toggle split
-
-    # Make the current focus fullscreen
-    bindsym $mod+f fullscreen
-
-    # Toggle the current focus between tiling and floating mode
-    bindsym $mod+Shift+space floating toggle
-
-    # Swap focus between the tiling area and the floating area
-    bindsym $mod+space focus mode_toggle
-
-    # Move focus to the parent container
-    bindsym $mod+a focus parent
-#
-# Scratchpad:
-#
-    # Sway has a "scratchpad", which is a bag of holding for windows.
-    # You can send windows there and get them back later.
-
-    # Move the currently focused window to the scratchpad
-    bindsym $mod+Shift+minus move scratchpad
-
-    # Show the next scratchpad window or hide the focused scratchpad window.
-    # If there are multiple scratchpad windows, this command cycles through them.
-    bindsym $mod+minus scratchpad show
-#
-# Resizing containers:
-#
+set $menu dmenu_path | wmenu -f '$font' | xargs swaymsg exec --
+
+exec swayidle -w \
+    timeout 300 'swaylock -f -c 000000' \
+    timeout 310 'swaymsg "output * power off"' \
+    resume 'swaymsg "output * power on"' \
+    before-sleep 'swaylock -f -c 000000'
+
+input * {
+    repeat_delay 200
+    repeat_rate 45
+    xkb_layout us,ir
+}
+
+floating_modifier $mod normal
+
+bindsym $mod+Return exec $term
+bindsym $mod+Shift+Return exec $term -a 'footfl'
+for_window [app_id="footfl"] floating enable
+bindsym $mod+space exec $menu
+bindsym $mod+backslash exec passmenu --type -f '$font'
+
+bindsym $mod+Shift+w kill
+
+bindsym $mod+Shift+c reload
+bindsym $mod+Shift+r restart
+
+set $mode_system System (l)ock | (e)xit sway | (s)uspend | (h)ibernate | (r)eboot | (S)hutdown
+mode "$mode_system" {
+    bindsym l       exec swaylock -f -c 000000, mode "default"
+    bindsym e       exec swaymsg exit,          mode "default"
+    bindsym s       exec sudo pm-suspend,       mode "default"
+    # bindsym h       exec systemctl hibernate,   mode "default"
+    bindsym r       exec sudo reboot,           mode "default"
+    bindsym Shift+s exec sudo poweroff,         mode "default"
+
+    bindsym Return  mode "default"
+    bindsym Escape  mode "default"
+    bindsym q       mode "default"
+}
+bindsym $mod+Shift+e mode "$mode_system"
+
+bindsym $mod+apostrophe exec dmenu-light
+bindsym XF86MonBrightnessUp exec light -A 5
+bindsym XF86MonBrightnessDown exec light -U 5
+
+bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
+bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK -5%
+bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
+bindsym $mod+XF86AudioRaiseVolume exec pactl set-source-volume @DEFAULT_SOURCE@ +5%
+bindsym $mod+XF86AudioLowerVolume exec pactl set-source-volume @DEFAULT_SOURCE@ -5%
+bindsym $mod+XF86AudioMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle
+
+bindsym $mod+$left focus left
+bindsym $mod+$down focus down
+bindsym $mod+$up focus up
+bindsym $mod+$right focus right
+
+bindsym $mod+Shift+$left move left
+bindsym $mod+Shift+$down move down
+bindsym $mod+Shift+$up move up
+bindsym $mod+Shift+$right move right
+
+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
+bindsym $mod+bracketleft workspace prev
+bindsym $mod+bracketright workspace next
+
+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
+bindsym $mod+Shift+bracketleft move container to workspace prev
+bindsym $mod+Shift+bracketright move container to workspace next
+
+# bspwm-esque workspace switch and container move
+bindsym $mod2+bracketleft        exec b-ws-util sway switch prev
+bindsym $mod2+bracketright       exec b-ws-util sway switch next
+bindsym $mod2+Shift+bracketleft  exec b-ws-util sway move prev follow
+bindsym $mod2+Shift+bracketright exec b-ws-util sway move next follow
+
+bindsym $mod+Shift+backslash splith
+bindsym $mod+minus splitv
+
+bindsym $mod+s layout stacking
+bindsym $mod+w layout tabbed
+bindsym $mod+e layout toggle split
+
+bindsym $mod+f fullscreen
+
+bindsym $mod+period floating toggle
+bindsym $mod+comma focus mode_toggle
+
+bindsym $mod+a focus parent
+bindsym $mod+Shift+a focus child
+
+bindsym $mod+Shift+s sticky toggle
+
+bindsym $mod+Shift+o move scratchpad
+bindsym $mod+o scratchpad show
+
 mode "resize" {
-    # left will shrink the containers width
-    # right will grow the containers width
-    # up will shrink the containers height
-    # down will grow the containers height
     bindsym $left resize shrink width 10px
     bindsym $down resize grow height 10px
     bindsym $up resize shrink height 10px
     bindsym $right resize grow width 10px
 
-    # Ditto, with arrow keys
-    bindsym Left resize shrink width 10px
-    bindsym Down resize grow height 10px
-    bindsym Up resize shrink height 10px
-    bindsym Right resize grow width 10px
-
-    # Return to default mode
     bindsym Return mode "default"
     bindsym Escape mode "default"
+    bindsym q      mode "default"
 }
 bindsym $mod+r mode "resize"
 
-#
-# Status Bar:
-#
-# Read `man 5 sway-bar` for more information about this section.
 bar {
-    position top
+    position bottom
 
-    # When the status_command prints a new line to stdout, swaybar updates.
-    # The default just shows the current date and time.
-    status_command while date +'%Y-%m-%d %X'; do sleep 1; done
+    # status_command while date +'%a, %d %b %Y %T %z'; do sleep 1; done
+    status_command my-bar
 
     colors {
         statusline #ffffff
-        background #323232
+        background #000000
         inactive_workspace #32323200 #32323200 #5c5c5c
     }
 }
 
-include /etc/sway/config.d/*
+for_window [window_role="pop-up"] floating enable
+
+for_window [app_id="mpv"] floating enable
+for_window [app_id="mumble"] floating enable
+for_window [app_id="nm-connection-editor"] floating enable
+for_window [app_id="virt-manager"] floating enable
+for_window [class="Vncviewer"] floating enable
+for_window [class="TigerVNC Viewer"] floating enable
+for_window [app_id="thunar"] floating enable
+for_window [app_id="pavucontrol"] floating enable
+
+include ~/.config/sway/`hostname`
+
+exec dbus-update-activation-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK
+exec [ -x "$(command -v nm-applet)" ] && nm-applet
+exec sleep 1 && xrdb -merge ~/.Xresources
diff --git a/.config/sway/nostalgia b/.config/sway/nostalgia
new file mode 100644
index 0000000..857c864
--- /dev/null
+++ b/.config/sway/nostalgia
@@ -0,0 +1,14 @@
+# -*-conf-*-
+
+output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
+
+input "1739:31251:DLL07BE:01_06CB:7A13_Touchpad" {
+    dwt enabled
+    natural_scroll enabled
+    middle_emulation enabled
+    click_method clickfinger
+}
+
+input * {
+    xkb_options ctrl:swap_rwin_rctl,grp:shifts_toggle
+}
diff --git a/.local/bin/b-ws-util b/.local/bin/b-ws-util
index df921f7..6ca5fe9 100755
--- a/.local/bin/b-ws-util
+++ b/.local/bin/b-ws-util
@@ -31,10 +31,10 @@ else
 fi
 
 if [ "$op" = "switch" ]; then
-  i3 workspace "$dest_ws"
+  "$1" workspace number "$dest_ws"
 elif [ "$op" = "move" ]; then
-  i3 move container to workspace "$dest_ws"
+  "$1" move container to workspace number "$dest_ws"
   if [ "$4" = "follow" ]; then
-    i3 workspace "$dest_ws"
+    "$1" workspace number "$dest_ws"
   fi
 fi
diff --git a/.local/bin/my-bar b/.local/bin/my-bar
new file mode 100755
index 0000000..18f8a92
--- /dev/null
+++ b/.local/bin/my-bar
@@ -0,0 +1,20 @@
+#!/bin/sh
+while true
+do
+    b0="/sys/class/power_supply/BAT0"
+    bat="$(cat $b0/capacity)"
+    # batl="$(cat $b0/capacity_level)"
+    pm="pamixer --get-volume"
+    pmm="pamixer --get-mute"
+    vol="$($pm)"
+    [ "$($pmm)" = "true" ] && volm='-' || volm='+'
+    volmic="$($pm --default-source)"
+    [ "$($pmm --default-source)" = "true" ] && volmicm='-' || volmicm='+'
+    load="$(cat /proc/loadavg | cut -d' ' -f1)"
+    time="$(date +'%a, %-d %b %Y %R %z')"
+	printf "%s%% | %s%s,%s%s | %s | %s\n" \
+           "$bat" \
+           "$vol" "$volm" "$volmic" "$volmicm" \
+           "$load" "$time"
+	sleep 5
+done
diff --git a/.local/bin/passmenu b/.local/bin/passmenu
index d3e7c75..777c5db 100755
--- a/.local/bin/passmenu
+++ b/.local/bin/passmenu
@@ -24,8 +24,8 @@ if [[ $1 == "--type" ]]; then
 fi
 
 if [[ -n $WAYLAND_DISPLAY ]]; then
-	dmenu=dmenu-wl
-	xdotool="ydotool type --file -"
+	dmenu=wmenu
+	xdotool="wtype -"
 elif [[ -n $DISPLAY ]]; then
 	dmenu=dmenu
 	xdotool="xdotool type --clearmodifiers --file -"
-- 
cgit v1.2.3-83-g751a