# _________    ________             __________
# ______  /_______  __/_____ ____  ____  /_  /_
# _  __  /_  _ \_  /_ _  __ `/  / / /_  /_  __/
# / /_/ / /  __/  __/ / /_/ // /_/ /_  / / /_
# \__,_/  \___//_/    \__,_/ \__,_/ /_/  \__/
#
# Logo key. Use Mod1 for Alt.
set $mod Mod4

# Home row direction keys, like vim
set $left h
set $down j
set $up k
set $right l

# Your preferred terminal emulator
set $term alacritty
set $term_fallback 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 wofi --show=drun | xargs swaymsg exec --
set $menu_fallback wofi --show=run | xargs swaymsg exec --

# Workspaces' names
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"

# Pure Wayland
# xwayland disable

#                         __________
# _______ ___________________(_)_  /______________
# __  __ `__ \  __ \_  __ \_  /_  __/  __ \_  ___/
# _  / / / / / /_/ /  / / /  / / /_ / /_/ /  /
# /_/ /_/ /_/\____//_/ /_//_/  \__/ \____//_/
#
# You can get the names of your outputs by running: swaymsg -t get_outputs
output DP-2 resolution 1920x1080 position -1920,0
output eDP-1 resolution 1920x1080 position 0,0
output HDMI-A-1 resolution 1920x1080 position 1920,0

# _____                      _____
# ___(_)__________________  ___  /_
# __  /__  __ \__  __ \  / / /  __/
# _  / _  / / /_  /_/ / /_/ // /_
# /_/  /_/ /_/_  .___/\__,_/ \__/
#             /_/
# 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.
input type:touchpad {
    tap enabled
    tap_button_map lrm
    dwt enabled
    natural_scroll enabled
    events disabled_on_external_mouse
}

input type:keyboard {
    xkb_layout us,jp
    xkb_options grp:rshift_toggle
}

input * xkb_numlock enable

# _______       _____             _____              _____
# ___    |___  ___  /_______________  /______ _________  /_
# __  /| |  / / /  __/  __ \_  ___/  __/  __ `/_  ___/  __/
# _  ___ / /_/ // /_ / /_/ /(__  )/ /_ / /_/ /_  /   / /_
# /_/  |_\__,_/ \__/ \____//____/ \__/ \__,_/ /_/    \__/
#
exec pipewire
exec mpd
exec start_notify
exec wl-paste -t text --watch clipman store
exec swayidle -w \
         timeout 300 'swaylock' \
         timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
         before-sleep 'swaylock'
exec mpDris2
exec swaywpp
# exec emacs --daemon

# ______           ______
# ___  /______________  /__
# __  /_  __ \  __ \_  //_/
# _  / / /_/ / /_/ /  ,<
# /_/  \____/\____//_/|_|
#
# Status Bar:
# Read `man 5 sway-bar` for more information about this section.
bar {
    swaybar_command waybar
}

# gaps
gaps outer 5
gaps inner 5
# smart_gaps on

# title bar
font Sarasa Mono J 12
titlebar_border_thickness 0
titlebar_padding 11 1

# border, no title
for_window [app_id="^.*"] border pixel 2, opacity 1
default_border pixel 2
default_floating_border pixel 2
# smart_borders on
# hide_edge_borders smart

# cursor theme
seat seat0 xcursor_theme Breeze_Snow 24

# gtk theme
exec_always {
    gsettings set org.gnome.desktop.interface gtk-theme 'Arc-Dark'
    gsettings set org.gnome.desktop.interface icon-theme 'Papirus-Dark'
    # gsettings set org.gnome.desktop.interface document-font-name 'Iosevka Aile 10'
    # gsettings set org.gnome.desktop.interface font-name 'Iosevka Slab 10'
    # gsettings set org.gnome.desktop.interface monospace-font-name 'Sarasa Mono J 10'
    gsettings set org.gnome.desktop.interface cursor-theme 'Breeze_Snow'
    gsettings set org.gnome.desktop.interface cursor-size '24'
}

# Nord
set $light #eceff4
set $dark #2e3440
set $focusedborder #eceff4
set $inactiveborder #ebcb8b
set $unfocusedborder #81a1c1
set $urgentborder #bf616a
# OneDark
# set $light #dfdfdf
# set $dark #282c34
# set $focusedborder #dfdfdf
# set $inactiveborder #e5c07b
# set $unfocusedborder #61afef
# set $urgentborder #e06c75

# class                  border            bg                text    indicator         child_border 
client.focused           $focusedborder		 $focusedborder	   $dark	 $focusedborder	   $focusedborder
client.focused_inactive  $inactiveborder	 $inactiveborder	 $dark	 $inactiveborder	 $inactiveborder
client.unfocused         $unfocusedborder	 $unfocusedborder  $light	 $unfocusedborder  $unfocusedborder
client.urgent            $urgentborder		 $urgentborder		 $light	 $urgentborder		 $urgentborder

# ______              ______ _____       _____________
# ___  /___________  ____  /____(_)____________  /__(_)_____________ ________
# __  //_/  _ \_  / / /_  __ \_  /__  __ \  __  /__  /__  __ \_  __ `/_  ___/
# _  ,<  /  __/  /_/ /_  /_/ /  / _  / / / /_/ / _  / _  / / /  /_/ /_(__  )
# /_/|_| \___/_\__, / /_.___//_/  /_/ /_/\__,_/  /_/  /_/ /_/_\__, / /____/
#             /____/                                         /____/
# Basics:
#
# Start a terminal
bindsym $mod+Return exec $term
bindsym $mod+Shift+Return exec $term_fallback

# Kill focused window
bindsym $mod+q kill

# Start your launcher
bindsym $mod+d exec $menu
bindsym $mod+Control+d exec $menu_fallback

# Window switcher
bindsym $mod+Control+w exec wofiswaywin.py

# Web search
bindsym $mod+Mod1+s exec searchmenu --wofi
bindsym $mod+Control+s exec bukumenu --wofi

# Manga
bindsym $mod+Mod1+m exec mangamenu --wofi

# Clipboard manager
bindsym $mod+Mod1+d exec clipboard --wofi
bindsym $mod+Mod1+c exec clipboard --clear
bindsym $mod+c exec clipman clear --tool wofi

# Media keys
bindsym XF86AudioRaiseVolume exec volumecontrol increase && pkill -x -RTMIN+11 waybar
bindsym XF86AudioLowerVolume exec volumecontrol decrease && pkill -x -RTMIN+11 waybar
bindsym XF86AudioMute exec volumecontrol toggle && pkill -x -RTMIN+11 waybar
bindsym --locked XF86AudioPlay exec playerctl play-pause
bindsym --locked XF86AudioNext exec playerctl next
bindsym --locked XF86AudioPrev exec playerctl previous

# Brightness
bindsym XF86MonBrightnessDown exec brightness down
bindsym XF86MonBrightnessUp exec brightness up

# Screenshot
bindsym Print exec screenshot --region
bindsym $mod+Print exec screenshot --full

# Dismiss notifications
bindsym $mod+Mod1+n exec dismiss_notify

# Emacs
bindsym $mod+Mod1+e exec emacsclient -c -a emacs

# Lock
bindsym $mod+Shift+x exec swaylock
bindsym --locked $mod+Mod1+a output * dpms on
bindsym --locked $mod+Mod1+z output * dpms off

# 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+r reload

# Exit sway (logs you out of your Wayland session)
bindsym $mod+Mod1+q exec swaynag -t warning \
        -m "Logout" \
        -b "Exit session" "swaymsg exit" \
        -b "Suspend" "loginctl suspend" \
        -b "Hibernate" "loginctl hibernate" \
        -b "Hybrid sleep" "loginctl hybrid-sleep" \
        -b "Suspend then hibernate" "loginctl suspend-then-hibernate" \
        -b "Shutdown" "loginctl poweroff" \
        -b "Reboot" "loginctl reboot"

#
# 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

# 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

#
# 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

# Move focus to the child container
bindsym $mod+Shift+a focus child

# Make window sticky
bindsym $mod+Shift+s sticky toggle

#
# 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:
#
mode "resize" {
    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 $mod+r mode "resize"

#
# Workspaces:
#
# Switch to workspace
bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10
# Move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10

#               ______
# ___________  ____  /____________
# __  ___/  / / /_  /_  _ \_  ___/
# _  /   / /_/ /_  / /  __/(__  )
# /_/    \__,_/ /_/  \___//____/
#
# Floating
for_window [app_id="info.febvre.Komikku"] floating enable
for_window [class="Gimp-2.10"] floating enable
for_window [app_id="org.inkscape.Inkscape"] floating enable
for_window [class="krita"] floating enable
for_window [title="About Mozilla Firefox"] floating enable
for_window [title="Picture-in-Picture"] floating enable

# Specify workspaces for applications
assign [app_id="thunderbird"] $ws3
assign [app_id="org.pwmt.zathura"] $ws4
assign [app_id="mpv"] $ws6
assign [class="Element"] $ws7
assign [app_id="org.telegram.desktop.desktop"] $ws7
