File manager integration ======================== Have you ever thought about how we start a new work in ``i3``? This is our typical workflow: - We launch an application with Alt+D or Alt+Shift+D [1]_, or - we open a file manager with Alt+T, choose a file and then launch the associated application. File manager usage in scratchpad -------------------------------- In every day work we usually work with applications and file managers on the same project but never at the same time! This is why it is very handy to keep file manager windows in the background not mixing them with application windows. This ``i3`` configuration separates usual application windows from file manager windows. File manager windows are kept in the *scratchpad* of ``i3`` allowing to make them appear and disappear without disturbing application windows. +-------------+--------------------------------------------+ | Alt+T | Opens a file manager instance, | +-------------+--------------------------------------------+ | Alt+- | hides it, [2]_ | +-------------+--------------------------------------------+ | Alt+- | unhides it one by one by pressing the same | | | key again, [3]_ | +-------------+--------------------------------------------+ | Alt+< | hides all file manager windows, | +-------------+--------------------------------------------+ | Alt+< | unhides all filemanger windows at the same | | | time by pressing the same key again. [4]_ | +-------------+--------------------------------------------+ | Alt+Shift+Q | closes the file manager. | +-------------+--------------------------------------------+ Table: File manager usage in ``i3`` For “drag and drop” copy operations you need to see more then one file manager window at the same time. Use Alt+< to toggle ``view all file managers``. As all file manager windows have the same default size and position you will see only the top window. Move the top window manually, then the underlaying window become visible. Press the Alt+< key again to make them disappear. Another handy way to hide and show the file manager is the ``gtrayicon`` as shown in red below. It has the same function as Alt+<. .. figure:: ./images/gtrayicon.png :alt: Hide/unhide filemanager windows with gtrayicon :width: 60.0% Hide/unhide filemanager windows with gtrayicon Source code of file manager integration --------------------------------------- The following source code lines launch the ``Thunar`` file manager. To change replace the keyword “thunar” with your preferred file manager. Install the ``gtrayicon`` package (Debian, Ubuntu) .. code:: bash sudo apt-get install gtrayicon Append the following to ``/etc/i3/config``: .. rubric:: ``/etc/i3/conf`` excerpt .. code:: bash bindsym Alt+t exec thunar bindsym Alt+minus scratchpad show for_window [class="Thunar"] move scratchpad; [class="Thunar"] scratchpad show; bindsym Alt+less [class="Thunar"] scratchpad show exec gtrayicon --tooltip="Hide/show file manager." --activate='i3-msg [class="Thunar"] scratchpad show;' --deactivate='i3-msg [class="Thunar"] scratchpad show;' Exit mode ========= The standard configuration defines Alt+Shift+e to exit ``i3``. It will send you back to the login screen. Exit mode usage --------------- The new exit mode defines the following shortcuts: +----------------+------------------------------------+ | Alt+Shift+X, L | Lock the screen. | +----------------+------------------------------------+ | Alt+Shift+X, E | Exit ``i3`` (same as Alt+Shift+E). | +----------------+------------------------------------+ | Alt+Shift+X, S | Suspend. | +----------------+------------------------------------+ | Alt+Shift+X, H | Hibernate. | +----------------+------------------------------------+ | Alt+Shift+X, R | Reboot. | +----------------+------------------------------------+ | Alt+Shift+X, D | Shutdown. | +----------------+------------------------------------+ Table: Exit mode usage Source code ----------- Append the following to ``/etc/i3/config``: .. rubric:: Debian 8/Debian 9 extract of ``/etc/i3/config`` .. code:: bash # New exit mode. set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (d) shutdown mode "$mode_system" { bindsym l exec --no-startup-id i3lock, mode "default" bindsym e exec --no-startup-id "i3-nagbar -t warning -m 'You pressed the exit shortcut. All unsaved data will be lost.' -b 'Yes, exit i3' 'i3-msg exit'", mode "default" bindsym s exec --no-startup-id i3lock, mode default; exec --no-startup-id /bin/systemctl suspend, mode "default" bindsym h exec --no-startup-id i3lock, mode default; exec --no-startup-id /bin/systemctl hibernate, mode "default" bindsym r exec --no-startup-id "i3-nagbar -t warning -m 'You pressed the reboot shortcut. All unsaved data will be lost.' -b 'Yes, reboot' '/bin/systemctl reboot'", mode "default" bindsym d exec --no-startup-id "i3-nagbar -t warning -m 'You pressed the shutdown shortcut. All unsaved data will be lost.' -b 'Yes, shutdown' '/bin/systemctl poweroff'", mode "default" # back to normal: Enter or Escape bindsym Return mode "default" bindsym Escape mode "default" } bindsym $mod+Shift+x mode "$mode_system" .. Important:: Your system policy might not allow users to suspend, power off, hibernate and restart. The rights to do so are defined in: ``/usr/share/polkit-1/actions/org.freedesktop.login1.policy``. A step by step howto can be found `here `__. Create the following file: .. rubric:: Sample file: ``/etc/polkit-1/localauthority/50-local.d/org.freedesktop.consolekit.pkla`` .. code:: bash ### Make shure that all users are part of the group `users`. # gpasswd -a thomas users # See https://wiki.debianforum.de/Xfce [Local restart] Identity=unix-group:users Action=org.freedesktop.consolekit.system.restart ResultAny=yes ResultInactive=no ResultActive=yes [Local shutdown] Identity=unix-group:users Action=org.freedesktop.consolekit.system.stop ResultAny=yes ResultInactive=no ResultActive=yes [Local restart - multiple] Identity=unix-group:users Action=org.freedesktop.consolekit.system.restart-multiple-users ResultAny=yes ResultInactive=no ResultActive=yes [Local shutdown - multiple] Identity=unix-group:users Action=org.freedesktop.consolekit.system.stop-multiple-users ResultAny=yes ResultInactive=no ResultActive=yes # See also # https://wiki.archlinux.org/index.php/NetworkManager # See also group definitions here # https://wiki.debian.org/SystemGroups [Local shutdown - multiple] Identity=unix-group:netdev Action=org.freedesktop.ModemManager1.Device.Control ResultAny=yes ResultInactive=no ResultActive=yes Pass-through mode ================= What makes ``i3`` so convenient is that most of the actions can be controlled with a simple keystroke. All ``i3`` functions are bound to the a user defined modifier key which is usually the Alt or the Win key. Combinations with this modifier key like Alt+Return are interpreted by ``i3`` and are *not* farwarded to the active window. But in some cases it is necessary to pass such an ``i3`` key sequence to the active window. +---------------------+---------------------------------------------------+ | Alt+Shift+Backspace | disables temporarily all ``i3`` key bindings | | | forwarding all key strokes to the active window. | +---------------------+---------------------------------------------------+ | Alt+Shift+Backspace | re-enables all ``i3`` key bindings. | +---------------------+---------------------------------------------------+ Table: Pass-through-mode usage in ``i3`` Append the following to ``/etc/i3/config``: .. rubric:: Source code of pass-through mode. .. code:: bash set $passthrough_keys Suspend all window manager keys exit: Mod+Shift+Backspace mode "$passthrough_keys" { bindcode Alt+Shift+22 mode "default" } bindcode Alt+Shift+22 mode "$passthrough_keys" Date stamper ============ The ``YYYYMMDD-`` prefix in filenames like for example in ``20150225-minutes.doc`` is very useful to archive files chronologically. The Alt+Shift+N time stamper shortcut copies the current date into the clipboard from where it can be pasted with Ctrl+V or the middle mouse button. +--------------+---------------------------------------------------+ | Alt+Shift+N, | Copies and pastes the current date at the cursor | | Ctrl+V | position. | +--------------+---------------------------------------------------+ | Alt+Shift+N, | Copies and pastes the current date at the mouse | | middle mouse | pointer position. | | button | | +--------------+---------------------------------------------------+ Table: Date stamper usage Append the following to ``/etc/i3/config``: .. rubric:: Source code of date stamper .. code:: java bindsym $mod+Shift+n exec "echo $(date +%Y%m%d)- |tr -d '\n'| xclip -selection c"; exec "echo $(date +%Y%m%d)- |tr -d '\n'| xclip" .. [1] ``bindsym $mod+Shift+d exec xfce4-appfinder`` .. [2] When another window is selected press the key twice to hide. .. [3] It actually cycles through all windows in the scratchpad. .. [4] The windows might by stacked and you see only the top one. Move them manually.