nwg-piotr / autotiling

Script for sway and i3 to automatically switch the horizontal / vertical window split orientation
GNU General Public License v3.0
926 stars 30 forks source link

I cant get it to do anything when running from sway config. #55

Closed a73s closed 6 months ago

a73s commented 6 months ago

I'm running exec_always autotiling as the first line in my config and it doesn't do anything. When I run autotiling in a terminal window it works perfectly. Im on fedora 40 with autotiling version 1.9.1 installed using pip and python 3.12.3.

nwg-piotr commented 6 months ago

Well, what can I say? It should work this way. Could you paste your sway config?

a73s commented 6 months ago

in ~/.config/sway/config :

exec_always autotiling

gaps inner 0
gaps outer 0

exec sleep 1 && nextcloud
exec sleep 1 && /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=keepassxc --file-forwarding org.keepassxc.KeePassXC @@ %f @@ 
#exec sleep 1 && dnfdragora-updater

### Variables
#
# 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
# 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 | dmenu | xargs swaymsg exec --
set $menu wofi | xargs swaymsg exec --

### Output configuration
# walpaper used for background and lockscreen
set $wallpaper '/usr/share/backgrounds/gnome/adwaita-d.jxl'
# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)
output * bg $wallpaper fill
set $output-primary DP-1
# set $output-secondary DP-2

# Monitors
# You can get the names of your outputs by running: swaymsg -t get_outputs

# default display config
output DP-1 {
    resolution 3840x2160@143.999Hz 
    position 1920,0 
    scale 1.5 
    adaptive_sync on
}

# # workspace settings
# workspace 1 output $output-primary
# workspace 2 output $output-primary
# workspace 3 output $output-primary
# workspace 4 output $output-primary
# workspace 5 output $output-primary
# workspace 6 output $output-primary
# workspace 7 output $output-primary
# workspace 8 output $output-primary
# workspace 9 output $output-primary
# workspace 10 output $output-secondary

### Idle configuration
# defining locker so I can use it for a bind later
set $locker swaylock -l -c 5f5f5f -i '$wallpaper' --show-failed-attempts --daemonize
# this script is what actually runs the swayidle command
exec /bin/bash ~/.config/sway/idle.sh '$wallpaper'
# inhibit idle/display poweroff when playing audio
exec sway-audio-idle-inhibit

### Input configuration
# mice
input * {

    accel_profile flat
    middle_emulation diabled
}
# keyboards
input * {

    xkb_numlock enabled
}

### Key bindings
# Media:
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
bindsym Print exec grimshot save area - | wl-copy
bindsym Mod1+Print exec grimshot save area

#To raise the volume
bindsym XF86AudioRaiseVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ --limit 1.0
#To lower the volume
bindsym XF86AudioLowerVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
#To mute/unmute the volume
bindsym XF86AudioMute exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
#To mute/unmute the microphone
bindsym XF86AudioMicMute exec wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
#
# Basics:
#
    # Start a terminal
    bindsym $mod+Return exec $term

    # Start screen locker
    bindsym $mod+Mod1+l exec $locker

    # Kill focused window
    #bindsym $mod+Shift+q kill
    bindsym $mod+q kill

    # Start your launcher
    bindsym $mod+Space 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+Mod1+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:
#
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"

#
# Status Bar:
#
# Read `man 5 sway-bar` for more information about this section.
#bar {
#    position top
#
#    # 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 %I:%M:%S %p'; do sleep 1; done
#    status_command while date +'%m-%d-%Y %I:%M %p'; do sleep 1; done
#    tray_padding 10
#    output DP-1
#
#    colors {
#        statusline #ffffff
#        background #323232
#        inactive_workspace #32323200 #32323200 #5c5c5c
#    }
#}
exec waybar

include /etc/sway/config.d/*

although i doubt it matters, in ~/.config/sway/idle.sh

#!/bin/bash

locker="swaylock -l -c 5f5f5f --show-failed-attempts --daemonize -i '$1'"

swayidle -w timeout 600 'swaymsg "output * power off"' \
    resume 'swaymsg "output * power on"' \
    timeout 620 "$locker" \
    timeout 900 'systemctl suspend' \
    before-sleep "$locker"
nwg-piotr commented 6 months ago

Looks all right. Maybe you could try executing it later, not at the very top?

a73s commented 6 months ago

Double checked that and it still does not work. My current theory is that there's something that fedora installs with the sway desktop package group that interferes with it, ill play around with that and report back.

nwg-piotr commented 6 months ago

Well, I don't like PyPi, so never installed from there. Dunno if it matters.

a73s commented 6 months ago

OK... I got it working. I followed the exact manual install instructions on the readme and it works. Interestingly if I move it to ~/bin/ instead of /bin/ then It works in my terminal and not in the config, just like installing with pip. I think the issue was because of a difference between the PATH for my user terminal and whatever PATH the sway config uses. Thank you <3

nwg-piotr commented 5 months ago

Your ~/bin must be not in path from the point of view of sway.