From 7c8e48227f2f0f77968290527576079fa06fdf7b Mon Sep 17 00:00:00 2001 From: pivodevat Date: Tue, 25 Mar 2025 01:47:41 +0300 Subject: [PATCH] init --- conf.d/binds/base | 24 +++++++++++++ conf.d/binds/movement | 72 +++++++++++++++++++++++++++++++++++++ conf.d/binds/scratchpad | 9 +++++ conf.d/binds/utilites | 12 +++++++ conf.d/binds/workspaces | 46 ++++++++++++++++++++++++ conf.d/common | 13 +++++++ conf.d/startup | 5 +++ conf.d/status-bar | 12 +++++++ config | 29 +++++++++++++++ scripts/bar-toggle | 11 ++++++ scripts/brightness | 19 ++++++++++ scripts/volume | 22 ++++++++++++ scripts/workspace-manager | 75 +++++++++++++++++++++++++++++++++++++++ 13 files changed, 349 insertions(+) create mode 100644 conf.d/binds/base create mode 100644 conf.d/binds/movement create mode 100644 conf.d/binds/scratchpad create mode 100644 conf.d/binds/utilites create mode 100644 conf.d/binds/workspaces create mode 100644 conf.d/common create mode 100644 conf.d/startup create mode 100644 conf.d/status-bar create mode 100644 config create mode 100755 scripts/bar-toggle create mode 100755 scripts/brightness create mode 100755 scripts/volume create mode 100755 scripts/workspace-manager diff --git a/conf.d/binds/base b/conf.d/binds/base new file mode 100644 index 0000000..7b084e0 --- /dev/null +++ b/conf.d/binds/base @@ -0,0 +1,24 @@ +# Start a terminal +bindsym $mod+Return exec $term +bindsym Control+Alt+t exec $term +bindsym $mod+Shift+r reload + +# Kill focused window +bindsym Alt+F4 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' + diff --git a/conf.d/binds/movement b/conf.d/binds/movement new file mode 100644 index 0000000..2456589 --- /dev/null +++ b/conf.d/binds/movement @@ -0,0 +1,72 @@ +# Make the current focus fullscreen +bindsym $mod+f fullscreen + +# Toggle the current focus between tiling and floating mode. $mod+click to move. +bindsym $mod+Shift+space floating toggle +# Move focus to the parent container +bindsym $mod+a focus parent +# Swap focus between the tiling area and the floating area +bindsym $mod+space focus mode_toggle + +# +# Focus +# +# 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 + +# +# 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 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 $mod+r mode "resize" + +# +# Split +# +# You can "split" the current object of your focus with +# $mod+b or $mod+v, for horizontal and vertical splits +# respectively. +bindsym $mod+h 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 diff --git a/conf.d/binds/scratchpad b/conf.d/binds/scratchpad new file mode 100644 index 0000000..4d3d5f3 --- /dev/null +++ b/conf.d/binds/scratchpad @@ -0,0 +1,9 @@ +# 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 diff --git a/conf.d/binds/utilites b/conf.d/binds/utilites new file mode 100644 index 0000000..c435e50 --- /dev/null +++ b/conf.d/binds/utilites @@ -0,0 +1,12 @@ +# Special keys to adjust volume via PulseAudio +bindsym --locked XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle +bindsym --locked XF86AudioRaiseVolume exec ~/.config/sway/scripts/volume + +bindsym --locked XF86AudioLowerVolume exec ~/.config/sway/scripts/volume - +bindsym --locked XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle + +# Special keys to adjust brightness via brightnessctl +bindsym XF86MonBrightnessUp exec ~/.config/sway/scripts/brightness + +bindsym XF86MonBrightnessDown exec ~/.config/sway/scripts/brightness - + +# Special key to take a screenshot with grim +bindsym Print exec grim diff --git a/conf.d/binds/workspaces b/conf.d/binds/workspaces new file mode 100644 index 0000000..162a5ab --- /dev/null +++ b/conf.d/binds/workspaces @@ -0,0 +1,46 @@ +# Switch to workspace +bindsym $mod+1 exec ~/.config/sway/scripts/workspace-manager 1 +bindsym $mod+2 exec ~/.config/sway/scripts/workspace-manager 2 +bindsym $mod+3 exec ~/.config/sway/scripts/workspace-manager 3 +bindsym $mod+4 exec ~/.config/sway/scripts/workspace-manager 4 +bindsym $mod+5 exec ~/.config/sway/scripts/workspace-manager 5 +bindsym $mod+6 exec ~/.config/sway/scripts/workspace-manager 6 +bindsym $mod+7 exec ~/.config/sway/scripts/workspace-manager 7 +bindsym $mod+8 exec ~/.config/sway/scripts/workspace-manager 8 +bindsym $mod+9 exec ~/.config/sway/scripts/workspace-manager 9 +bindsym $mod+0 exec ~/.config/sway/scripts/workspace-manager 0 +bindsym $mod+F1 exec ~/.config/sway/scripts/workspace-manager F1 +bindsym $mod+F2 exec ~/.config/sway/scripts/workspace-manager F2 +bindsym $mod+F3 exec ~/.config/sway/scripts/workspace-manager F3 +bindsym $mod+F4 exec ~/.config/sway/scripts/workspace-manager F4 +bindsym $mod+F5 exec ~/.config/sway/scripts/workspace-manager F5 +bindsym $mod+F6 exec ~/.config/sway/scripts/workspace-manager F6 +bindsym $mod+F7 exec ~/.config/sway/scripts/workspace-manager F7 +bindsym $mod+F8 exec ~/.config/sway/scripts/workspace-manager F8 +bindsym $mod+F9 exec ~/.config/sway/scripts/workspace-manager F9 +bindsym $mod+F10 exec ~/.config/sway/scripts/workspace-manager F10 +bindsym $mod+F11 exec ~/.config/sway/scripts/workspace-manager F11 +bindsym $mod+F12 exec ~/.config/sway/scripts/workspace-manager F12 +# Move focused container to workspace +bindsym $mod+Shift+1 exec ~/.config/sway/scripts/workspace-manager 1 move +bindsym $mod+Shift+2 exec ~/.config/sway/scripts/workspace-manager 2 move +bindsym $mod+Shift+3 exec ~/.config/sway/scripts/workspace-manager 3 move +bindsym $mod+Shift+4 exec ~/.config/sway/scripts/workspace-manager 4 move +bindsym $mod+Shift+5 exec ~/.config/sway/scripts/workspace-manager 5 move +bindsym $mod+Shift+6 exec ~/.config/sway/scripts/workspace-manager 6 move +bindsym $mod+Shift+7 exec ~/.config/sway/scripts/workspace-manager 7 move +bindsym $mod+Shift+8 exec ~/.config/sway/scripts/workspace-manager 8 move +bindsym $mod+Shift+9 exec ~/.config/sway/scripts/workspace-manager 9 move +bindsym $mod+Shift+0 exec ~/.config/sway/scripts/workspace-manager 0 move +bindsym $mod+Shift+F1 exec ~/.config/sway/scripts/workspace-manager F1 move +bindsym $mod+Shift+F2 exec ~/.config/sway/scripts/workspace-manager F2 move +bindsym $mod+Shift+F3 exec ~/.config/sway/scripts/workspace-manager F3 move +bindsym $mod+Shift+F4 exec ~/.config/sway/scripts/workspace-manager F4 move +bindsym $mod+Shift+F5 exec ~/.config/sway/scripts/workspace-manager F5 move +bindsym $mod+Shift+F6 exec ~/.config/sway/scripts/workspace-manager F6 move +bindsym $mod+Shift+F7 exec ~/.config/sway/scripts/workspace-manager F7 move +bindsym $mod+Shift+F8 exec ~/.config/sway/scripts/workspace-manager F8 move +bindsym $mod+Shift+F9 exec ~/.config/sway/scripts/workspace-manager F9 move +bindsym $mod+Shift+F10 exec ~/.config/sway/scripts/workspace-manager F10 move +bindsym $mod+Shift+F11 exec ~/.config/sway/scripts/workspace-manager F11 move +bindsym $mod+Shift+F12 exec ~/.config/sway/scripts/workspace-manager F12 move diff --git a/conf.d/common b/conf.d/common new file mode 100644 index 0000000..eb79cd2 --- /dev/null +++ b/conf.d/common @@ -0,0 +1,13 @@ +# Keyboard +input * xkb_layout "us,ru" +input * xkb_options "grp:alt_shift_toggle" + +# Touchpad +input type:touchpad { + dwt enabled + tap enabled + middle_emulation enabled +} + +# Wallpaper +output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill diff --git a/conf.d/startup b/conf.d/startup new file mode 100644 index 0000000..6d14a5d --- /dev/null +++ b/conf.d/startup @@ -0,0 +1,5 @@ +# Start your nontification daemon +exec mako +# Start your audio daemon +exec pulseaudio --start + diff --git a/conf.d/status-bar b/conf.d/status-bar new file mode 100644 index 0000000..313496a --- /dev/null +++ b/conf.d/status-bar @@ -0,0 +1,12 @@ +bar { + status_command while date +'%Y-%m-%d %X'; do sleep 1; done + + mode invisible + colors { + statusline #ffffff + background #323232 + inactive_workspace #32323200 #32323200 #5c5c5c + } +} + +bindsym $mod+b exec ~/.config/sway/scripts/bar-toggle diff --git a/config b/config new file mode 100644 index 0000000..8e8f321 --- /dev/null +++ b/config @@ -0,0 +1,29 @@ +# Sexi-sway config + +# +# Variables +# +# Logo key. Use Mod1 for Alt. +set $mod Mod4 +# Home row direction keys, like SexNvim +set $left j +set $down k +set $up l +set $right semicolon + +# Your preferred terminal emulator +set $term foot + +# Your preferred application launcher +set $menu wmenu-run + +default_border none +input type:touchpad { + dwt enabled + tap enabled + middle_emulation enabled +} + +include /etc/sway/config.d/* +include ~/.config/sway/conf.d/* +include ~/.config/sway/conf.d/binds/* diff --git a/scripts/bar-toggle b/scripts/bar-toggle new file mode 100755 index 0000000..c7d70fb --- /dev/null +++ b/scripts/bar-toggle @@ -0,0 +1,11 @@ +#!/bin/bash + +bar_config=$(swaymsg -t get_bar_config "bar-0") + +mode=$(echo "$bar_config" | jq -r '.mode') + +if [ "$mode" == "dock" ]; then + swaymsg "bar mode invisible" +elif [ "$mode" == "invisible" ]; then + swaymsg "bar mode dock" +fi diff --git a/scripts/brightness b/scripts/brightness new file mode 100755 index 0000000..474cf5a --- /dev/null +++ b/scripts/brightness @@ -0,0 +1,19 @@ +#!/bin/bash + +NOTIFICATION_ID=9999 +CURRENT_BRIGHTNESS=$(brightnessctl g) +MAX_BRIGHTNESS=$(brightnessctl m) +CURRENT_BRIGHTNESS_PERCENT=$((CURRENT_BRIGHTNESS * 100 / MAX_BRIGHTNESS)) + +if [ "$1" == "+" ]; then + brightnessctl set +1% +elif [ "$1" == "-" ]; then + brightnessctl set 10%- +else + notify-send -u normal -r $NOTIFICATION_ID "Ошибка" "Неверный параметр. Используйте '+' или '-'." + exit 1 +fi + +UPDATED_BRIGHTNESS=$(brightnessctl g) +UPDATED_BRIGHTNESS_PERCENT=$((UPDATED_BRIGHTNESS * 100 / MAX_BRIGHTNESS)) +notify-send -u normal -i display-brightness-high -r $NOTIFICATION_ID "Уровень яркости" "${UPDATED_BRIGHTNESS_PERCENT}%" -t 400 diff --git a/scripts/volume b/scripts/volume new file mode 100755 index 0000000..5620f56 --- /dev/null +++ b/scripts/volume @@ -0,0 +1,22 @@ +#!/bin/bash + +MAX_VOLUME=200 +NOTIFICATION_ID=9999 +CURRENT_VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -oP '\d+%' | head -1 | tr -d '%') + +if [ "$1" == "+" ]; then + if [ "$CURRENT_VOLUME" -lt "$MAX_VOLUME" ]; then + pactl set-sink-volume @DEFAULT_SINK@ +10% + else + notify-send -u normal -r $NOTIFICATION_ID "Невозможно увеличить звук" "Достигнут лимит в $MAX_VOLUME%" -t 400 + exit 0 + fi +elif [ "$1" == "-" ]; then + pactl set-sink-volume @DEFAULT_SINK@ -10% +else + notify-send -u normal -r $NOTIFICATION_ID "Error" "Invalid parameter. Use '+' or '-'." -t 400 + exit 1 +fi + +UPDATED_VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -oP '\d+%' | head -1 | tr -d '%') +notify-send -u normal -i audio-volume-high -r $NOTIFICATION_ID "Уровень звука" "${UPDATED_VOLUME}%" -t 400 diff --git a/scripts/workspace-manager b/scripts/workspace-manager new file mode 100755 index 0000000..5be6db9 --- /dev/null +++ b/scripts/workspace-manager @@ -0,0 +1,75 @@ +#!/bin/bash + +# Calc swich +key_input=$1 +flag=$2 + +workspace_number=$(swaymsg -t get_workspaces | jq -r '.[] | select(.focused==true) | .name') +last_workspace=$(cat /tmp/last_workspace 2>/dev/null) +f_key_number=$(cat /tmp/f_key_number 2>/dev/null || echo 0) +digit_key_number=$(cat /tmp/digit_key_number 2>/dev/null || echo 0) + +case $key_input in + F1) f_key_number=1 ;; + F2) f_key_number=2 ;; + F3) f_key_number=3 ;; + F4) f_key_number=4 ;; + F5) f_key_number=5 ;; + F6) f_key_number=6 ;; + F7) f_key_number=7 ;; + F8) f_key_number=8 ;; + F9) f_key_number=9 ;; + F10) f_key_number=10 ;; + F11) f_key_number=11 ;; + F12) f_key_number=12 ;; + 0) digit_key_number=10;; + [1-9]) digit_key_number=$key_input ;; + *) echo "Invalid key input"; exit 1 ;; +esac +workspace_number=$((f_key_number * 10 + digit_key_number)) + +# Hooks +case $workspace_number in + 30) workspace_number=48 ;; # Krita +esac + +# swich +if [[ $flag == "move" ]]; then + swaymsg move container to workspace number $workspace_number +else + swaymsg workspace $workspace_number +fi + +echo "$current_workspace" > /tmp/last_workspace +echo "$f_key_number" > /tmp/f_key_number +echo "$digit_key_number" > /tmp/digit_key_number +# End swich + + + + + +# Post swich +case $workspace_number in + 51) + xinput set-prop "ASUE1305:00 04F3:3212 Touchpad" "libinput Disable While Typing Enabled" 0 + ;; + 48) + xinput set-prop "ASUE1305:00 04F3:3212 Touchpad" "libinput Disable While Typing Enabled" 0 + ;; + 30) + xinput set-prop "ASUE1305:00 04F3:3212 Touchpad" "libinput Disable While Typing Enabled" 0 + ;; + 18) + xinput set-prop "ASUE1305:00 04F3:3212 Touchpad" "libinput Disable While Typing Enabled" 0 + ;; + *) + xinput set-prop "ASUE1305:00 04F3:3212 Touchpad" "libinput Disable While Typing Enabled" 1 + ;; +esac + +case $workspace_number in + *) + setxkbmap us; sleep 0.1; setxkbmap -layout "us,ru" -option "grp:alt_shift_toggle" + ;; +esac