Airblader / i3

A fork of the i3 window manager with gaps and some other features. :warning: i3-gaps has been merged into i3.
BSD 3-Clause "New" or "Revised" License
5.88k stars 321 forks source link

`i3-save-tree` outputs improper JSON #401

Closed CodingPenguin1 closed 3 years ago

CodingPenguin1 commented 3 years ago

I'm submitting a…

[x] Bug
[ ] Feature Request
[ ] Documentation Request
[ ] Other (Please describe in detail)

Current Behavior

Ran i3-save-tree --workspace 11 > ~/.config/i3/workspace-11.json, got:

// vim:ts=4:sw=4:et
{
    "border": "pixel",
    "current_border_width": 0,
    "floating": "auto_off",
    "geometry": {
       "height": 1400,
       "width": 2540,
       "x": 4930,
       "y": 750
    },
    "marks": [],
    "name": "Discord",
    "percent": 0.6,
    "swallows": [
       {
       // "class": "^discord$",
       // "instance": "^discord$",
       // "title": "^Discord$",
       // "window_role": "^browser\\-window$"
       }
    ],
    "type": "con"
}

{
    "border": "pixel",
    "current_border_width": 0,
    "floating": "auto_off",
    "geometry": {
       "height": 600,
       "width": 800,
       "x": 0,
       "y": 0
    },
    "marks": [],
    "name": "Spotify Premium",
    "percent": 0.4,
    "swallows": [
       {
       // "class": "^Spotify$",
       // "instance": "^spotify$",
       // "title": "^Spotify\\ Premium$"
       }
    ],
    "type": "con"
}

Error is:

ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set ', 'set   ', 'set_from_resource', 'bindsym', 'bindcode', 'bind', 'bar', 'font', 'mode', 'gaps', 'smart_borders', 'smart_gaps', 'floating_minimum_size', 'floating_maximum_size', 'floating_modifier', 'default_orientation', 'workspace_layout', 'default_border', 'new_window', 'default_floating_border', 'new_float', 'hide_edge_borders', 'for_window', 'assign', 'no_focus', 'focus_follows_mouse', 'mouse_warping', 'focus_wrapping', 'force_focus_wrapping', 'force_xinerama', 'force-xinerama', 'disable_randr15', 'disable-randr15', 'workspace_auto_back_and_forth', 'fake_outputs', 'fake-outputs', 'force_display_urgency_hint', 'focus_on_window_activation', 'title_align', 'show_marks', 'workspace', 'ipc_socket', 'ipc-socket', 'ipc_kill_timeout', 'restart_state', 'popup_during_fullscreen', 'exec_always', 'exec', 'client.background', 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent', 'client.placeholder'
ERROR: CONFIG: (in file /home/rjslater/.config/i3/config)
ERROR: CONFIG: Line 281: # Autostart apps on workspaces
ERROR: CONFIG: Line 282: #exec sleep 5 && i3-msg 'workspace number 11; exec discord' && sleep 5 && i3-msg 'exec spotify' && sleep 2 && i3-msg 'workspace number 10; exec mailspring' && sleep 5 && i3-msg 'workspace number 1'
ERROR: CONFIG: Line 283: i3-msg "workspace 11; append_layout ~/.config/i3/workspace-11.json"
ERROR: CONFIG:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR: CONFIG: Line 284: 
ERROR: CONFIG: Line 285: 
ERROR: FYI: You are using i3 version 4.19.1 (2021-02-01)
ERROR: Layout file is invalid: found an empty swallow definition.
ERROR: JSON parsing error: parse error: client cancelled parse via callback return value
           "^browser\\-window$"        }     ],     "type": "con" }  {
                     (right here) ------^

ERROR: No output found at destination coordinates. Not repositioning.
ERROR: JSON parsing error: parse error: unallowed token at this point in JSON text
           }     ],     "type": "con" },  {     "border": "pixel",    
                     (right here) ------^

ERROR: Could not parse "/home/rjslater/.config/i3/workspace-11.json" as JSON, not loading.
ERROR: No output found at destination coordinates. Not repositioning.

Expected Behavior

File to be formatted in proper JSON so append_layout functions properly.

Reproduction Instructions

i3-save-tree --workspace 11 > ~/.config/i3/workspace-11.json Add i3-msg "workspace 11; append_layout ~/.config/i3/workspace-11.json" to i3 config

Environment

i3 version 4.19.1

Output of i3 --moreversion 2>&-:

Binary i3 version:  4.19.1 (2021-02-01) © 2009 Michael Stapelberg and contributors
Running i3 version: 4.19.1 (2021-02-01) (pid 1065)
Loaded i3 config: /home/rjslater/.config/i3/config (Last modified: Wed 07 Jul 2021 11:04:34 PM EDT, 792 seconds ago)

The i3 binary you just called: /usr/bin/i3
The i3 binary you are running: i3

i3 config:

# ----- Core -----

# Modkey
set $mod Mod4

# Font
font pango:monospace 12

# Make i3 support transparency
exec --no-startup-id picom &

# Natural scrolling
exec --no-startup-id synclient HorizEdgeScroll=1 VertEdgeScroll=1 VertScrollDelta=-111

# Hide window borders/titlebars
for_window [class="^.*"] border pixel 0

# Make windows with these titles start floating
for_window [title="\[floating].*"] floating enable
for_window [class="(y|Y)akuake"] floating enable
for_window [title="Figure \d*"] floating enable

# Gaps
gaps inner 10

# Use dunst for managing notifications, notify-send to send them
exec killall -q notify-osd
exec --no-startup-id dunst -config $HOME/.config/dunst/config

# Load GTK Themes for Nautilus, etc
exec gnome-settings-daemon

# ----- WORKSPACES -----

# Force workspaces to specific monitors
workspace 1 output HDMI-0
workspace 2 output DP-2
workspace 3 output HDMI-0
workspace 4 output DP-2
workspace 5 output HDMI-0
workspace 6 output DP-2
workspace 7 output HDMI-0
workspace 8 output DP-2
workspace 9 output HDMI-0
workspace 10 output DP-2
workspace 11 output DP-5
workspace 12 output DP-0

# 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
bindsym $mod+minus workspace number 11
bindsym $mod+equal workspace number 12

# 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
bindsym $mod+Shift+minus move container to workspace number 11
bindsym $mod+Shift+equal move container to workspace number 12

# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right

# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# move focused window
bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+semicolon move right

# alternatively, you can use the cursor 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

# split in horizontal orientation
bindsym $mod+Shift+h split h

# split in vertical orientation
bindsym $mod+Shift+v split v

# ----- CONTAINER SHORTCUTS -----

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# kill focused window
bindsym Control+q kill

# enter fullscreen mode for the focused container
#bindsym $mod+Shift+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
#bindsym $mod+s layout stacking
#bindsym $mod+w layout tabbed
#bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
#bindsym $mod+Shift+f focus mode_toggle

# focus the parent container
#bindsym $mod+a focus parent

# focus the child container
#bindsym $mod+d focus child

# ----- i3 SESSION SHORTCUTS -----

# reload the configuration file
bindsym $mod+Shift+c reload

# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart

# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"

# resize window (you can also use the mouse for that)
mode "resize" {
        # These bindings trigger as soon as you enter the resize mode

        # Pressing left will shrink the window’s width.
        # Pressing right will grow the window’s width.
        # Pressing up will shrink the window’s height.
        # Pressing down will grow the window’s height.
        bindsym j resize shrink width 10 px or 10 ppt
        bindsym k resize grow height 10 px or 10 ppt
        bindsym l resize shrink height 10 px or 10 ppt
        bindsym semicolon resize grow width 10 px or 10 ppt

        # same bindings, but for the arrow keys
        bindsym Left resize shrink width 10 px or 10 ppt
        bindsym Down resize grow height 10 px or 10 ppt
        bindsym Up resize shrink height 10 px or 10 ppt
        bindsym Right resize grow width 10 px or 10 ppt

        # back to normal: Enter or Escape or $mod+r
        bindsym Return mode "default"
        bindsym Escape mode "default"
        bindsym $mod+r mode "default"
}

bindsym $mod+r mode "resize"

# ----- APP LAUNCHERS -----

# Albert uses in-app setting to bind kbd shortcut
exec /usr/bin/albert

# Code
bindsym $mod+c exec code

# Web Browsers
bindsym $mod+w exec qutebrowser
bindsym $mod+Shift+w exec brave

# GMail
#bindsym $mod+g exec thunderbird-beta
bindsym $mod+g exec mailspring

# Music player
bindsym $mod+m exec spotify

# File manager
bindsym $mod+Shift+f exec "nautilus $HOME"
#bindsym $mod+f exec "alacritty -e vifm $HOME $HOME/Documents"

# Pilot
bindsym $mod+Shift+p exec $HOME/.config/i3/openPilot.py

# Pulse sms
bindsym $mod+t exec pulse-sms

# Terminal
bindsym $mod+Return exec alacritty

# Xkill
bindsym $mod+Shift+q exec alacritty -e xkill

# XFCE4 Appfinder
bindsym $mod+a exec xfce4-appfinder

# Screensaver
#bindsym $mod+l exec xscreensaver-command -lock
bindsym $mod+Escape exec ~/.config/i3/i3lock.sh

# Youtube
bindsym $mod+y exec "brave youtube.com/feed/subscriptions"

# Flameshot for screenshots
bindsym $mod+p exec $HOME/.config/dunst/screenshot.sh flameshot select

# OBS Studio
bindsym $mod+o exec obs

# Note-taker
#for_window [ title="notetaker_window" ] floating enable
#bindsym $mod+n exec alacritty -e /home/rjslater/Utils/bin/notes -t notetaker_window

# ----- OTHER CONTROLS -----

# Volume controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume $(cat /home/rjslater/.config/i3/.currentAudioOutput) +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume $(cat /home/rjslater/.config/i3/.currentAudioOutput) -5% #decrease sound volume
bindsym XF86AudioMute        exec --no-startup-id pactl set-sink-mute $(cat /home/rjslater/.config/i3/.currentAudioOutput) toggle # mute sound
bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause

# Poweroff shortcut
bindsym $mod+Ctrl+Shift+p exec poweroff

# Cycle audio output device
bindsym $mod+n exec ~/.config/i3/changeAudioDevice.py

# ----- AUTOSTART SCRIPTS -----

# Set display resolutions and refresh rates
exec --no-startup-id sleep 1 && ~/.screenlayout/quadruple_monitor.sh

# Set default browser to qutebrowser
exec xdg-settings set default-web-browser org.qutebrowser.qutebrowser.desktop &

# Set soundbar as default audio device
exec pactl set-default-sink alsa_output.pci-0000_0c_00.4.analog_stereo

# Gromit-mpx annotation software
exec gromit-mpx

# Start unclutter to autohide cursor
exec unclutter -idle 2 -jitter 2 -root &

# Polybar
exec_always --no-startup-id sleep 1 && $HOME/.config/polybar/launch.sh main secondary tertiary quaternary

# Disable display blanking
exec xset -dpms s off
exec xset s noblank

# Start facelocker
exec --no-startup-id facelocker -c ~/.config/facelocker/config.json

# Mount Karen
exec --no-startup-id ~/Utils/bin/mountsystem Karen rjslater 48567

# Yakuake
exec --no-startup-id yakuake &

# Autostart apps on workspaces
#exec sleep 5 && i3-msg 'workspace number 11; exec discord' && sleep 5 && i3-msg 'exec spotify' && sleep 2 && i3-msg 'workspace number 10; exec mailspring' && sleep 5 && i3-msg 'workspace number 1'
i3-msg "workspace 11; append_layout ~/.config/i3/workspace-11.json"

# Set wallpaper
#exec --no-startup-id sleep 1 && DISPLAY=:0 nitrogen --restore &
exec sleep 10 && DISPLAY=:0 feh --bg-scale --randomize ~/Pictures/Wallpapers/Wallpaper_Cycle
Airblader commented 3 years ago

i3-save-tree generates a layout file, but requires some manual editing because you need to define the match criteria. The script helpfully generates possible criteria, but commented out, which makes the JSON invalid and is for the user to fix. Please refer to the documentation on layout saving and restoring.

Closing as invalid & also because this is not specific to i3-gaps.