From 171edb3962d820bae716ac1c6b8e226fcb6bd2f3 Mon Sep 17 00:00:00 2001 From: Andreas Gerlach <andi@appelgriebsch.org> Date: Wed, 22 Jul 2020 16:33:29 +0200 Subject: [PATCH] [sway] introduce new modes for screenshots, screen-recording --- overlays/sway/etc/skel/README.md | 28 ++++++++++++++++------ overlays/sway/etc/sway/modes/default | 7 ++---- overlays/sway/etc/sway/modes/recording | 32 +++++++++++++++++++++++++ overlays/sway/etc/sway/modes/resize | 14 +++++++---- overlays/sway/etc/sway/modes/screenshot | 20 ++++++++++++++++ overlays/sway/etc/xdg/waybar/style.css | 5 +--- 6 files changed, 85 insertions(+), 21 deletions(-) create mode 100644 overlays/sway/etc/sway/modes/recording create mode 100644 overlays/sway/etc/sway/modes/screenshot diff --git a/overlays/sway/etc/skel/README.md b/overlays/sway/etc/skel/README.md index 78ccd205..c2baa381 100644 --- a/overlays/sway/etc/skel/README.md +++ b/overlays/sway/etc/skel/README.md @@ -46,7 +46,6 @@ Sway has up to ten different workspaces that can be freely arranged on the avail - toggle full-screen for the current application window: **$mod** + **f** - split the current application window vertically: **$mod** + **v** - split the current application window horizontally: **$mod** + **b** -- enter resize mode for the current application window: **$mod** + **r** (see [Resize Mode](#Resize%20Mode)) ## Changing the Container Layout @@ -64,9 +63,10 @@ Sway has up to ten different workspaces that can be freely arranged on the avail After activating the Resize Mode you should see a message in the statusbar. +- enter resize mode for the current application window: **$mod** + **r** - resize the current application window: **\<movement-key\>** (can be used together with **Shift** for larger offsets) -- increase the gaps between windows: **+** (can be used together with **Shift** for larger offsets) -- decrease the gaps between windows: **-** (can be used together with **Shift** for larger offsets) +- increase the gaps between windows: **+** +- decrease the gaps between windows: **-** - exit the resize mode: **Enter** or **ESC** ## Scratchpad Mode @@ -76,11 +76,25 @@ Sway has a "scratchpad", which is a bag of holding for windows. You can send wi - move the current application window to the Scratchpad: **$mod** + **Shift** + **Minus** - activate the Scratchpad Mode: **$mod** + **Minus** -## Screenshots +## Screenshot Mode -- screenshot of the whole screen: **Print Screen** -- screenshot of the current application window: **$mod** + **Print Screen** -- screenshot of certain area of the screen: **$mod** + **Shift** + **Print Screen** +- enter screenshot mode: **$mod** + **Shift** + **s** +- copy screenshot of the whole screen: **f** +- save screenshot of the whole screen: **Shift** + **f** +- copy screenshot of the application window: **w** +- save screenshot of the application window: **Shift** + **w** +- copy screenshot of certain area of the screen: **r** +- save screenshot of certain area of the screen: **Shift** + **r** +- exit the resize mode: **Enter** or **ESC** + +## Screenshot Recording Mode + +- enter screenshot recording mode: **$mod** + **Shift** + **r** +- record the whole screen: **f** +- record the whole screen with audio: **Shift** + **f** +- record a certain area of the screen: **r** +- record a certain area of the screen with audio: **Shift** + **r** +- exit the resize mode: **Enter** or **ESC** ## Restart / Exit diff --git a/overlays/sway/etc/sway/modes/default b/overlays/sway/etc/sway/modes/default index 9f38c789..8d4c6d5b 100644 --- a/overlays/sway/etc/sway/modes/default +++ b/overlays/sway/etc/sway/modes/default @@ -25,15 +25,12 @@ bindsym $mod+Shift+c reload # Exit sway (logs you out of your Wayland session) bindsym $mod+Shift+e exec $logout -# Taking screenshots (full-screen, active window, or dedicated area) -bindsym Print exec grimshot save screen -bindsym $mod+Print exec grimshot save win -bindsym $mod+Shift+Print exec grimshot save area - # Media key bindings bindsym XF86AudioLowerVolume exec amixer -q sset 'Master' 5%- bindsym XF86AudioMute exec amixer -q sset 'Master' toggle bindsym XF86AudioRaiseVolume exec amixer -q sset 'Master' 5%+ + +# Screen brightness bindings bindsym XF86MonBrightnessDown exec light -U 5 bindsym XF86MonBrightnessUp exec light -A 5 diff --git a/overlays/sway/etc/sway/modes/recording b/overlays/sway/etc/sway/modes/recording new file mode 100644 index 00000000..952f611e --- /dev/null +++ b/overlays/sway/etc/sway/modes/recording @@ -0,0 +1,32 @@ +set $mode_recording "<span foreground='$base0A'>雷</span> \ +<span foreground='$base05'><b>Screen</b></span> <span foreground='$base0A'>(<b>w</b>)</span> \ +<span foreground='$base01'>—</span> \ +<span foreground='$base05'><b>Screen (+ Mic)</b></span> <span foreground='$base0A'>(<b>Shift+w</b>)</span> \ +<span foreground='$base01'>—</span> \ +<span foreground='$base05'><b>Region</b></span> <span foreground='$base0A'>(<b>r</b>)</span> \ +<span foreground='$base01'>—</span> \ +<span foreground='$base05'><b>Region (+ Mic)</b></span> <span foreground='$base0A'>(<b>Shift+r</b>)</span>" + +set $mode_recording_on "<span foreground='$base0A'>壘</span> \ +<span foreground='$base05'><b>Exit</b></span> <span foreground='$base0A'>(<b>ESC</b>)</span>" + +mode --pango_markup $mode_recording_on { + bindsym Escape exec killall -s SIGINT wf-recorder, mode "default" +} + +mode --pango_markup $mode_recording { + bindsym w exec killall -s SIGINT wf-recorder || wf-recorder --audio=0 -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') \ + -f ~/Videos/recording-$(date +'%Y-%m-%d-%H%M%S').mp4, mode $mode_recording_on + bindsym Shift+w exec killall -s SIGINT wf-recorder || wf-recorder --audio -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') \ + -f ~/Videos/recording-$(date +'%Y-%m-%d-%H%M%S').mp4, mode $mode_recording_on + bindsym r exec killall -s SIGINT wf-recorder || wf-recorder --audio=0 -g "$(slurp -d)" \ + -f ~/Videos/recording-$(date +'%Y-%m-%d-%H%M%S').mp4, mode $mode_recording_on + bindsym Shift+r exec killall -s SIGINT wf-recorder || wf-recorder --audio -g "$(slurp -d)" \ + -f ~/Videos/recording-$(date +'%Y-%m-%d-%H%M%S').mp4, mode $mode_recording_on + + # Return to default mode. + bindsym Escape mode "default" + bindsym Return mode "default" +} +bindsym $mod+Shift+r mode $mode_recording + diff --git a/overlays/sway/etc/sway/modes/resize b/overlays/sway/etc/sway/modes/resize index 0639f23f..6ef1df04 100644 --- a/overlays/sway/etc/sway/modes/resize +++ b/overlays/sway/etc/sway/modes/resize @@ -1,7 +1,11 @@ -# -# Resizing containers: -# -mode "resize" { +set $mode_resize "<span foreground='$base0A'></span> \ +<span foreground='$base05'><b>Resize</b></span> <span foreground='$base0A'>(<b>h/j/k/l</b>)</span> \ +<span foreground='$base01'>—</span> \ +<span foreground='$base05'><b>Increase Gaps</b></span> <span foreground='$base0A'>(<b>+</b>)</span> \ +<span foreground='$base01'>—</span> \ +<span foreground='$base05'><b>Decrease Gaps</b></span> <span foreground='$base0A'>(<b>-</b>)</span>" + +mode --pango_markup $mode_resize { # left will shrink the containers width # right will grow the containers width # up will shrink the containers height @@ -33,4 +37,4 @@ mode "resize" { bindsym Return mode "default" bindsym Escape mode "default" } -bindsym $mod+r mode "resize" +bindsym $mod+r mode $mode_resize diff --git a/overlays/sway/etc/sway/modes/screenshot b/overlays/sway/etc/sway/modes/screenshot new file mode 100644 index 00000000..8295e904 --- /dev/null +++ b/overlays/sway/etc/sway/modes/screenshot @@ -0,0 +1,20 @@ +set $mode_screenshot "<span foreground='$base0A'></span> \ +<span foreground='$base05'><b>Fullscreen</b></span> <span foreground='$base0A'>(<b>f</b>)</span> \ +<span foreground='$base01'>—</span> \ +<span foreground='$base05'><b>Window</b></span> <span foreground='$base0A'>(<b>w</b>)</span> \ +<span foreground='$base01'>—</span> \ +<span foreground='$base05'><b>Region</b></span> <span foreground='$base0A'>(<b>r</b>)</span>" + +mode --pango_markup $mode_screenshot { + bindsym f exec --no-startup-id grimshot copy screen, mode "default" + bindsym Shift+f exec --no-startup-id grimshot save screen ~/Pictures/screenshot-$(date +'%Y-%m-%d-%H%M%S'), mode "default" + bindsym w exec --no-startup-id grimshot copy win, mode "default" + bindsym Shift+w exec --no-startup-id grimshot save win ~/Pictures/screenshot-$(date +'%Y-%m-%d-%H%M%S'), mode "default" + bindsym r exec --no-startup-id grimshot copy area, mode "default" + bindsym Shift+r exec --no-startup-id grimshot save area ~/Pictures/screenshot-$(date +'%Y-%m-%d-%H%M%S'), mode "default" + + # Return to default mode. + bindsym Escape mode "default" + bindsym Return mode "default" +} +bindsym $mod+Shift+s mode $mode_screenshot diff --git a/overlays/sway/etc/xdg/waybar/style.css b/overlays/sway/etc/xdg/waybar/style.css index 5cc955a9..13268b4f 100644 --- a/overlays/sway/etc/xdg/waybar/style.css +++ b/overlays/sway/etc/xdg/waybar/style.css @@ -132,10 +132,7 @@ } #mode { - background: #64727D; - border-top: 2px solid #F5F7FA; - /* To compensate for the top border and still have vertical centering */ - padding-bottom: 2px; + background: #222E38; } #network { -- GitLab