Move sway from linux_home to nix style dir in root

This commit is contained in:
Martin Larsson 2025-01-23 16:55:30 +01:00
parent 8cb53fd6bd
commit ef5a1892d8
7 changed files with 0 additions and 0 deletions

51
sway/ayu_mirage Normal file
View file

@ -0,0 +1,51 @@
# colors.ayu
# Primary Colors
set $ayu_accent #FFCC66
set $ayu_bg #1F2430
set $ayu_fg #CCCAC2
set $ayu_ui #707A8C
# Functional Colors
set $ayu_tag #5CCFE6
set $ayu_func #FFD173
set $ayu_entity #73D0FF
set $ayu_string #D5FF80
set $ayu_regexp #95E6CB
set $ayu_markup #F28779
set $ayu_keyword #FFAD66
set $ayu_special #FFDFB3
set $ayu_comment #6C7A8B
set $ayu_constant #DFBFFF
set $ayu_operator #F29E74
set $ayu_error #FF6666
set $ayu_lsp_parameter #D3B8F9
# Layout & UI Colors
set $ayu_line #171B24
set $ayu_panel_bg #1C212B
set $ayu_panel_shadow #161922
set $ayu_panel_border #101521
set $ayu_gutter_normal #4A505A
set $ayu_gutter_active #757B84
set $ayu_selection_bg #274364
set $ayu_selection_inactive #23344B
set $ayu_selection_border #232A4C
set $ayu_guide_active #444A55
set $ayu_guide_normal #323843
# Version Control Colors
set $ayu_vcs_added #87D96C
set $ayu_vcs_modified #80BFFF
set $ayu_vcs_removed #F27983
set $ayu_vcs_added_bg #313D37
set $ayu_vcs_removed_bg #3E373A
# Miscellaneous Colors
set $ayu_fg_idle #707A8C
set $ayu_warning #FFA759

26
sway/catppuccin_macchiato Normal file
View file

@ -0,0 +1,26 @@
set $rosewater #f4dbd6
set $flamingo #f0c6c6
set $pink #f5bde6
set $mauve #c6a0f6
set $red #ed8796
set $maroon #ee99a0
set $peach #f5a97f
set $yellow #eed49f
set $green #a6da95
set $teal #8bd5ca
set $sky #91d7e3
set $sapphire #7dc4e4
set $blue #8aadf4
set $lavender #b7bdf8
set $text #cad3f5
set $subtext1 #b8c0e0
set $subtext0 #a5adcb
set $overlay2 #939ab7
set $overlay1 #8087a2
set $overlay0 #6e738d
set $surface2 #5b6078
set $surface1 #494d64
set $surface0 #363a4f
set $base #24273a
set $mantle #1e2030
set $crust #181926

174
sway/config Normal file
View file

@ -0,0 +1,174 @@
include ayu_mirage
# Remap caps lock to escape
input * {
xkb_options "caps:escape"
xkb_layout us,se
}
input "type:touchpad" {
# Palm detection (disable when typing)
dwt enabled
scroll_factor 0.2125
scroll_method two_finger
natural_scroll enabled
tap enabled
tap_button_map lrm
# Cannot change base sensitivity, in sway accel and sensitivity are are intertwined :(
pointer_accel 0.225
}
# Logo key. Use Mod1 for Alt.
set $mod Mod4
# Your preferred terminal emulator
set $term ghostty
# 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 --
### Output configuration
# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)
output * bg /home/larssonmartin1998-asahi/.config/wallpapers/catppuccin/cloudsnight.jpg fill
exec_always --no-startup-id ~/.config/sway/idle.sh
exec_always --no-startup-id ~/.config/sway/dim_inactive.windows.py
# https://github.com/ErikReider/SwayAudioIdleInhibit
# Prevents the system from locking when audio is playing or recording.
# This prevents the pc from shutting down when watching youtube for instance.
exec_always --no-startup-id sway-audio-idle-inhibit
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'
### Key bindings
# Start a terminal
bindsym $mod+Return exec $term
# Kill focused window
bindsym $mod+q kill
# Start your launcher
bindsym $mod+d exec $menu
# 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'
# Switch the keyboard layout
bindsym $mod+Shift+l exec ~/.config/sway/toggle_keyboard_layout.sh
#
# Moving around:
#
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
bindsym $mod+Shift+Left mark swap, focus left, swap container with mark swap, focus left
bindsym $mod+Shift+Down mark swap, focus down, swap container with mark swap, focus down
bindsym $mod+Shift+Up mark swap, focus up, swap container with mark swap, focus up
bindsym $mod+Shift+Right mark swap, focus right, swap container with mark swap, focus 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
#
# Layout stuff:
#
# Inverse the split to match neovim directions
bindsym $mod+Shift+v splith
bindsym $mod+Shift+h splitv
# Switch the current container between different layout styles
bindsym $mod+Shift+t layout tabbed
bindsym $mod+Shift+s layout toggle split
# Make the current focus fullscreen
bindsym $mod+Shift+f fullscreen
# Move focus to the parent container
bindsym $mod+Shift+a focus parent
# Resizing containers:
#
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 shrink height 10px
bindsym Up resize grow height 10px
bindsym Right resize grow width 10px
# Return to default mode
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+space mode "resize"
#
# Status Bar:
#
# Rea# target title bg text indicator border
client.focused $ayu_regexp $ayu_regexp $ayu_regexp $ayu_entity $ayu_regexp
client.focused_inactive $ayu_ui $ayu_ui $ayu_ui $ayu_entity $ayu_ui
client.unfocused $ayu_bg $ayu_bg $ayu_bg $ayu_entity $ayu_bg
client.urgent $ayu_keyword $ayu_bg $ayu_fg $ayu_ui $ayu_keyword
client.placeholder $ayu_ui $ayu_ui $ayu_fg $ayu_ui $ayu_ui
client.background $ayu_bg `man 5 sway-bar` for more information about this section.
# Hack to remove the titlebar or minimizing it.
font pango:CaskaydiaCove NFM SemiLight 1
default_border none
default_floating_border none
titlebar_padding 1
titlebar_border_thickness 0
bar {
position bottom
font pango:CaskaydiaCove NFM SemiLight 14
# When the status_command prints a new line to stdout, swaybar updates.
# status_command while date +'%Y-%m-%d %X'; do sleep 1; done
status_command ~/.config/sway/status.sh
colors {
background $ayu_bg
statusline $ayu_fg
focused_statusline $ayu_fg
focused_separator $ayu_bg
focused_workspace $ayu_bg $ayu_bg $ayu_accent
active_workspace $ayu_bg $ayu_bg $ayu_tag
inactive_workspace $ayu_bg $ayu_bg $ayu_ui
urgent_workspace $ayu_bg $ayu_bg $ayu_ui
binding_mode $ayu_bg $ayu_bg $ayu_ui
}
}
include /etc/sway/config.d/*

61
sway/dim_inactive.windows.py Executable file
View file

@ -0,0 +1,61 @@
#!/usr/bin/env python3
# From
# https://www.reddit.com/r/swaywm/comments/c4zb8l/dim_unfocused_windows/es0dg11/.
# This script is a modified version of the one from the link above with
# interrupt handler.
# This script requires i3ipc-python package (install it from a system package
# manager or pip).
# It makes inactive windows transparent. Use `TRANSPARENCY_VALUE` variable to
# control the transparency strength in range of 0…1; 0 is fully transparent.
# The most-recently active window on each monitor stays opaque, not just the
# active window.
import signal
import sys
from typing import Optional
import i3ipc
TRANSPARENCY_VALUE: str = '0.7875'
ipc = i3ipc.Connection()
g_prev_focused: Optional[i3ipc.con.Con] = None
g_prev_workspace: int = ipc.get_tree().find_focused().workspace().num
for window in ipc.get_tree():
if window.focused:
g_prev_focused = window
else:
window.command('opacity ' + TRANSPARENCY_VALUE)
def signal_handler(sig, frame):
for window in ipc.get_tree():
window.command('opacity 1.0')
sys.exit(0)
def on_window_focus(ipc: i3ipc.connection.Connection,
event: i3ipc.events.WindowEvent):
global g_prev_focused
global g_prev_workspace
focused = event.container
workspace = ipc.get_tree().find_focused().workspace().num
# https://github.com/swaywm/sway/issues/2859
if focused.id != g_prev_focused.id:
focused.command('opacity 1.0')
if workspace == g_prev_workspace:
g_prev_focused.command('opacity ' + TRANSPARENCY_VALUE)
g_prev_focused = focused
g_prev_workspace = workspace
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
ipc.on('window::focus', on_window_focus)
# Blocking call.
ipc.main()

24
sway/idle.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash
# Track the current inhibition state
inhibited=0
# Check player status and adjust idle inhibition
while true; do
if playerctl status | grep -q "Playing"; then
if [ "$inhibited" -eq 0 ]; then
swaymsg "inhibit_idle on"
inhibited=1
fi
else
if [ "$inhibited" -eq 1 ]; then
swaymsg "inhibit_idle off"
inhibited=0
fi
fi
sleep 5 # Check every 5 seconds
done &
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'

76
sway/status.sh Executable file
View file

@ -0,0 +1,76 @@
#!/bin/zsh
# Icons
vpn_icon=""
wifi_icon=" "
brightness_icon=""
bluetooth_icon=""
keyboard_icon="⌨"
date_icon=""
while true; do
# VPN (Mullvad)
vpn_status=$(mullvad status)
is_connected=$(echo "$vpn_status" | grep -c "Connected")
if [ "$is_connected" -eq 1 ]; then
visible_location=$(echo "$vpn_status" | grep -oP "Visible location:\s+\K.*" | cut -d. -f1)
vpn_display="$vpn_icon $visible_location"
else
vpn_display="$vpn_icon Disconnected"
fi
# Network status
ssid=$(nmcli -t -f ACTIVE,SSID dev wifi | grep -E '^yes' | cut -d: -f2)
if [ -z "$ssid" ]; then
network_display="$wifi_icon Disconnected"
else
network_display="$wifi_icon $ssid"
fi
# Date/time
date_time_icon="$date_icon $(date +"%a %b %d, %H:%M")"
# Battery
battery=$("$HOME/.config/confutils/get-battery.sh")
# Brightness
brightness=$(brightnessctl | grep -oP '[0-9]+(?=%)')
brightness_display="$brightness_icon $brightness%"
# Bluetooth
bluetooth_device=$(bluetoothctl devices Connected \
| awk '{$1=$2=""; print $0}' \
| sed 's/^ *//g')
if [ -z "$bluetooth_device" ]; then
bluetooth_display=""
else
bluetooth_display="$bluetooth_icon $bluetooth_device"
fi
# Keyboard layout
language_index=$(swaymsg -t get_inputs | jq -r '.[] | select(.type=="keyboard") | .xkb_active_layout_index' | head -n 1)
if [ "$language_index" -eq 0 ]; then
keyboard_layout="US"
else
keyboard_layout="SE"
fi
keyboard_display="$keyboard_icon $keyboard_layout"
# Combine all statuses, separated by tabs (\t).
# - In zsh, you can do literal tabs with $'\t'
final_status=""
if [ -n "$bluetooth_display" ]; then
final_status="$bluetooth_display"
fi
space=" "
final_status="$final_status$space$brightness_display"
final_status="$final_status$space$battery"
final_status="$final_status$space$keyboard_display"
final_status="$final_status$space$vpn_display"
final_status="$final_status$space$network_display"
final_status="$final_status$space$date_time_icon"
final_status="$final_status "
echo "$final_status"
sleep 1
done

10
sway/toggle_keyboard_layout.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/zsh
# Toggle between US (0) and Swedish (1) layouts
current=$(swaymsg -t get_inputs | jq -r '.[] | select(.type=="keyboard") | .xkb_active_layout_index' | head -n 1)
if [ "$current" -eq 0 ]; then
swaymsg input '*' xkb_switch_layout 1
else
swaymsg input '*' xkb_switch_layout 0
fi