Add i3 autostart scripts and media mode

This commit is contained in:
Marty Oehme 2019-12-02 19:43:07 +01:00
parent 2915f036fd
commit 2413f5ec42
2 changed files with 80 additions and 15 deletions

View file

@ -10,6 +10,7 @@
# Please see https://i3wm.org/docs/userguide.html for a complete reference! # Please see https://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4 set $mod Mod4
set $modemod Mod1
set $font "pango:Fira Code 8" set $font "pango:Fira Code 8"
# Font for window titles. Will also be used by the bar unless a different font # Font for window titles. Will also be used by the bar unless a different font
@ -17,6 +18,8 @@ set $font "pango:Fira Code 8"
#font pango:monospace 8 #font pango:monospace 8
font $font font $font
workspace_auto_back_and_forth yes
# This font is widely installed, provides lots of unicode glyphs, right-to-left # This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango). # text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8 #font pango:DejaVu Sans Mono 8
@ -107,7 +110,7 @@ set $ws6 "6"
set $ws7 "7" set $ws7 "7"
set $ws8 "8" set $ws8 "8"
set $ws9 "9" set $ws9 "9"
set $ws10 "10" set $ws10 "10:"
# switch to workspace # switch to workspace
bindsym $mod+1 workspace $ws1 bindsym $mod+1 workspace $ws1
@ -156,28 +159,56 @@ mode "resize" {
# back to normal: Enter or Escape or $mod+r # back to normal: Enter or Escape or $mod+r
bindsym Return mode "default" bindsym Return mode "default"
bindsym Escape mode "default" bindsym Escape mode "default"
bindsym $mod+r mode "default" bindsym $modemod+r mode "default"
} }
bindsym $mod+shift+r mode "resize" mode "media" {
# Pressing left will move 5s back
bindsym h exec playerctl position 5-
bindsym Shift+h exec playerctl position 15-
# Pressing down will move to the next file
bindsym j exec playerctl next
# Pressing up will move to the previous file
bindsym k exec playerctl previous
# Pressing right will move 5s forward
bindsym l exec playerctl position 5+
bindsym Shift+l exec playerctl position 30+
# Start i3bar to display a workspace bar (plus the system information i3status # Pressing p will play/pause current track
# finds out, if available) bindsym p exec playerctl play-pause
bar {
strip_workspace_numbers yes # Pressing p will play/pause current track
font $font bindsym s exec playerctl stop
position bottom
colors { #TODO add option to open file, loop, shuffle, show/select players
background #232323
statusline #DCDCDC # back to normal
} bindsym Return mode "default"
status_command i3status bindsym Escape mode "default"
bindsym $modemod+m mode "default"
} }
bindsym $modemod+r mode "resize"
bindsym $modemod+m mode "media"
# reload the configuration file # reload the configuration file
bindsym $mod+Shift+y reload bindsym $mod+Shift+y reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) # restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
# bindsym $mod+Shift+r restart bindsym $mod+Shift+r restart
# set a pretty wallpaper # set a pretty wallpaper
exec_always --no-startup-id feh --bg-scale ~/pictures/wall.jpg exec_always --no-startup-id feh --bg-scale ~/pictures/wall.jpg
# launch polybar (script ensures only 1 instance existing at a time)
exec_always --no-startup-id poly-launch
# default workspaces for most used apps
# assign [class="^qutebrowser$"] → number 1
# spotify needs for_window, see https://i3wm.org/docs/userguide.html#assign_workspace
for_window [class="^spotify$"] number "10:"
# autostart often used apps
# needs to be done like this to both automatically start the apps on correct workspace
# and not confine them there forever
exec $XDG_CONFIG_HOME/i3/scripts/i3-applications-autostart

View file

@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Wait for program coming up
wait_for_program() {
n=0
while true; do
# PID of last background command
if xdotool search --onlyvisible --pid $! 2>/dev/null; then
break
else
if [ $n -eq 200 ]; then
notify-send -u critical "Error during start: last program $! did not started fast enough"
break
else
n=$($n + 1)
sleep 0.1
fi
fi
done
}
i3-msg "workspace number 2:"
alacritty &
wait_for_program
i3-msg "workspace number 10:"
spotify &
wait_for_program
i3-msg "workspace number 1:"
qutebrowser &
wait_for_program
i3-msg "workspace number 3"