improve screenshot shortcuts

This commit is contained in:
Johannes Loher 2020-09-19 18:02:15 +02:00
parent 0c56e8d582
commit 152b878717
2 changed files with 110 additions and 24 deletions

View file

@ -2,6 +2,8 @@
# Variables # Variables
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
set $mod Mod4 set $mod Mod4
set $mod2 Mod1
set $color_bg_focused #2F343F set $color_bg_focused #2F343F
set $color_bg_unfocused #383C4A set $color_bg_unfocused #383C4A
@ -65,9 +67,9 @@ font pango:$font
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Launcher # Launcher
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
bindsym $mod+d exec --no-startup-id rofi -show drun bindsym $mod+d exec rofi -show drun
bindsym $mod+x exec --no-startup-id rofi -show run bindsym $mod+x exec rofi -show run
bindsym $mod+o exec --no-startup-id rofi-pass bindsym $mod+o exec rofi-pass
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Window management # Window management
@ -190,8 +192,8 @@ bindsym $mod+Shift+9 move container to workspace $workspace9
bindsym $mod+Shift+0 move container to workspace $workspace10 bindsym $mod+Shift+0 move container to workspace $workspace10
# move current workspace to output # move current workspace to output
bindsym $mod+Mod1+Right move workspace to output right bindsym $mod+$mod2+Right move workspace to output right
bindsym $mod+Mod1+Left move workspace to output left bindsym $mod+$mod2+Left move workspace to output left
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# sway management # sway management
@ -205,25 +207,25 @@ bindsym $mod+Shift+e exec "swaynag -f 'pango:$font' -t warning -m 'sway beenden?
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Program shortcuts # Program shortcuts
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
bindsym $mod+Return exec --no-startup-id termite bindsym $mod+Return exec termite
bindsym $mod+c exec --no-startup-id firefox bindsym $mod+c exec firefox
bindsym $mod+t exec --no-startup-id thunderbird bindsym $mod+t exec thunderbird
bindsym $mod+g exec --no-startup-id code bindsym $mod+g exec code
bindsym XF86Explorer exec --no-startup-id thunar bindsym XF86Explorer exec thunar
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Audio shortcuts # Audio shortcuts
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume $audio_out +5% bindsym XF86AudioRaiseVolume exec pactl set-sink-volume $audio_out +5%
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume $audio_out -5% bindsym XF86AudioLowerVolume exec pactl set-sink-volume $audio_out -5%
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute $audio_out toggle bindsym XF86AudioMute exec pactl set-sink-mute $audio_out toggle
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute $audio_in toggle bindsym XF86AudioMicMute exec pactl set-source-mute $audio_in toggle
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Video shortcuts # Video shortcuts
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
bindsym XF86MonBrightnessUp exec --no-startup-id xbacklight +10 bindsym XF86MonBrightnessUp exec xbacklight +10
bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -10 bindsym XF86MonBrightnessDown exec xbacklight -10
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Assignment of progrmans to workspaces # Assignment of progrmans to workspaces
@ -238,20 +240,25 @@ assign [class="^Slack$"] $workspace8
assign [class="^Microsoft Teams - Preview$"] $workspace9 assign [class="^Microsoft Teams - Preview$"] $workspace9
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Screenshot shortcut # Screenshot shortcuts
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
bindsym Print exec --no-startup-id grim bindsym Print exec $HOME/.local/bin/swaygrim --focused-output
bindsym Shift+Print exec $HOME/.local/bin/swaygrim --focused-window
bindsym $mod+Print exec $HOME/.local/bin/swaygrim --output
bindsym $mod+Shift+Print exec $HOME/.local/bin/swaygrim --window
bindsym $mod2+Print exec $HOME/.local/bin/swaygrim --manual
bindsym $mod+$mod2+Print exec $HOME/.local/bin/swaygrim --all
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Lockscreen # Lockscreen
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
exec --no-startup-id swayidle -w \ exec swayidle -w \
timeout 300 'swaylock -f' \ timeout 300 'swaylock -f' \
timeout 600 'swaymsg "output * dpms off"' \ timeout 600 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \ resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock -f' before-sleep 'swaylock -f'
bindsym control+Mod1+l exec --no-startup-id swaylock bindsym control+$mod2+l exec swaylock
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Window theming # Window theming
@ -263,10 +270,10 @@ client.unfocused $color_bg_unfocused $color_bg_unfocused $color_fg_unfocu
client.urgent $color_bg_unfocused $color_warn $color_fg_focused $color_bg_unfocused client.urgent $color_bg_unfocused $color_warn $color_fg_focused $color_bg_unfocused
# do not display edge borders # do not display edge borders
hide_edge_borders both #hide_edge_borders both
# do not display a titlebar in tiled layout # do not display a titlebar in tiled layout
default_border pixel 0 default_border none
# gaps # gaps
gaps inner 10 gaps inner 10
@ -282,12 +289,12 @@ bar {
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Applets # Applets
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
exec --no-startup-id nm-applet --indicator exec nm-applet --indicator
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Notification daemon # Notification daemon
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
exec --no-startup-id /usr/bin/mako exec /usr/bin/mako
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# GTK3 # GTK3

79
.local/bin/swaygrim Executable file
View file

@ -0,0 +1,79 @@
#! /bin/bash
# Copyright (c) 2020 Johannes Loher
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
print_usage() {
echo "Usage: swaygrim [command]"
echo
echo "Commands:"
echo " -a, --all Capture all outputs. This is the default if no option is given."
echo " -m, --manual Select a region manually and capture it."
echo " -o, --output Select an output and capture it."
echo " -O, --focused-output Capture the currently focused output"
echo " -w, --window Select a window and capture it."
echo " -W, --focused-window Capture the currently focused window"
echo " -h, --help Show help message and quit."
echo
}
all() {
grim
}
select_manual() {
DIMENSIONS=$(slurp)
grim -g "$DIMENSIONS"
}
select_output() {
DIMENSIONS=$(swaymsg -t get_outputs | jq -r '.[] | select(.active) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)
grim -g "$DIMENSIONS"
}
focused_output() {
grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')
}
select_window() {
DIMENSIONS=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)
grim -g "$DIMENSIONS"
}
focused_window() {
DIMENSIONS=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | select(.focused) | .rect | "\(.x),\(.y) \(.width)x\(.height)"')
grim -g "$DIMENSIONS"
}
case $1 in
-a|--all|"")
all
;;
-m|--manual)
select_manual
;;
-o|--output)
select_output
;;
-O|--focused-output)
focused_output
;;
-w|--window)
select_window
;;
-W|--focused-window)
focused_window
;;
-h|--help)
print_usage
;;
*)
print_usage
exit 1
;;
esac