Browse Source

Cleanup sway config and add better screenshot tool

master
Arti Zirk 5 years ago
parent
commit
915124d40a
  1. 37
      .bin/wscreenshot.py
  2. 80
      .config/sway/config

37
.bin/wscreenshot.py

@ -0,0 +1,37 @@
#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GLib
import time
import sys
import os
from subprocess import run
from urllib.parse import urljoin
file_name = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES)
file_name = os.path.join(file_name, time.strftime('screenshot_%Y-%m-%d-%H%M%S_grim.png'))
if len(sys.argv) < 2:
run(["grim", file_name], check=True)
else:
if sys.argv[1] in ('-h','--help'):
print("Usage: {} [-h|--help|--region|--window]".format(sys.argv[0]))
sys.exit(0)
elif sys.argv[1] == '--region':
region = run('slurp', check=True, capture_output=True)
run(["grim", '-g', '-', file_name], check=True, input=region.stdout)
elif sys.argv[1] == '--window':
tree = run(['swaymsg', '-t', 'get_tree'], check=True, capture_output=True)
regions = run(['jq', '-r', '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"'],
check=True, capture_output=True, input=tree.stdout)
region = run('slurp', check=True, capture_output=True, input=regions.stdout)
run(["grim", '-g', '-', file_name], check=True, input=region.stdout)
else:
sys.exit(1)
# Add created screenshot to Gtk recents list
recent_mgr = Gtk.RecentManager.get_default()
uri = urljoin("file:", file_name)
recent_mgr.add_item(uri)
GLib.idle_add(Gtk.main_quit)
Gtk.main()

80
.config/sway/config

@ -13,81 +13,62 @@ set $left h
set $down j set $down j
set $up k set $up k
set $right l set $right l
# Default font
set $font "xos4 Terminus 12"
font pango:xos4 Terminus 12
# Background image
set $bg "~/Pildid/background.png"
# Your preferred terminal emulator # Your preferred terminal emulator
set $term gnome-terminal set $term gnome-terminal
# Your preferred application launcher # Your preferred application launcher
# None: it's recommended that you pass the final command to sway # None: it's recommended that you pass the final command to sway
#set $menu dmenu_path | dmenu | xargs swaymsg exec set $menu rofi -modi drun -show drun -show-icons -normal-window -font $font
#set $menu gnome-terminal --title=swayapplauncher -- ~/.bin/desktop_launcher.sh
set $menu rofi -modi drun -show drun -show-icons -normal-window -font "xos4 Terminus 12"
### Output configuration ### Output configuration
# #
# Default wallpaper (more resolutions are available in __DATADIR__/backgrounds/sway/) # Default wallpaper (more resolutions are available in __DATADIR__/backgrounds/sway/)
output * bg ~/Pildid/background.png tile output * bg $bg tile
#
# Example configuration:
#
# output HDMI-A-1 resolution 1920x1080 position 1920,0
#
# You can get the names of your outputs by running: swaymsg -t get_outputs
# Work monitors
output "Dell Inc. DELL U2715H GH85D71K0W5S" pos 2560 0 output "Dell Inc. DELL U2715H GH85D71K0W5S" pos 2560 0
output "Dell Inc. DELL U2715H GH85D6CN1YYS" pos 0 0 output "Dell Inc. DELL U2715H GH85D6CN1YYS" pos 0 0
# Disable T480s laptop internal screen on lid close
set $laptop "Unknown 0x0791 0x00000000" set $laptop "Unknown 0x0791 0x00000000"
bindswitch lid:on output $laptop disable bindswitch lid:on output $laptop disable
bindswitch lid:off output $laptop enable bindswitch lid:off output $laptop enable
# load xresources
exec xrdb -load ~/.Xresources
# Notification daemon # Notification daemon
exec mako --default-timeout 10000 exec mako --default-timeout 10000
# Polkit agent # Polkit agent
exec ~/.bin/polkit-agent exec ~/.bin/polkit-agent
# Dropbox
exec ~/code/dropbox-filesystem-fix/dropbox_start.py
### Idle configuration ### Idle configuration
#
# Example configuration:
#
exec swayidle \ exec swayidle \
timeout 300 'swaylock -c 333333 -s tile -i ~/Pildid/background.png' \ timeout 300 'swaylock -c 333333 -s tile -i $bg' \
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 -c 333333 -s tile -i ~/Pildid/background.png' before-sleep 'swaylock -c 333333 -s tile -i $bg'
# Lock screen with scroll lock button # Lock screen with scroll lock button
bindsym Scroll_Lock exec swaylock -c 333333AA -s tile -i ~/Pildid/background.png bindsym Scroll_Lock exec swaylock -c 333333AA -s tile -i $bg
# This will lock your screen after 300 seconds of inactivity, then turn off
# your displays after another 600 seconds, and turn your screens back on when
# resumed. It will also lock your screen before your computer goes to sleep.
# Dropbox
exec ~/code/dropbox-filesystem-fix/dropbox_start.py
# load xresources
exec xrdb -load ~/.Xresources
# Alt+Tab window switcher
bindsym Alt+Tab exec ~/.bin/switch_window.py bindsym Alt+Tab exec ~/.bin/switch_window.py
### Input configuration # Hack that adds a emoji to all window titles so that title height is somewhat constant
# # You can read mode about this here https://github.com/swaywm/sway/issues/3114
# Example configuration:
#
# input "2:14:SynPS/2_Synaptics_TouchPad" {
# dwt enabled
# tap enabled
# natural_scroll enabled
# middle_emulation enabled
# }
#
# You can get the names of your inputs by running: swaymsg -t get_inputs
# Read `man 5 sway-input` for more information about this section.
font pango:xos4 Terminus 12
for_window [title=".*"] title_format ▪ %title for_window [title=".*"] title_format ▪ %title
### Key bindings ### Key bindings
@ -252,15 +233,17 @@ bindsym XF86AudioLowerVolume exec --no-startup-id amixer set Master 5%-
bindsym XF86MonBrightnessUp exec --no-startup-id brightnessctl --quiet set +5% bindsym XF86MonBrightnessUp exec --no-startup-id brightnessctl --quiet set +5%
bindsym XF86MonBrightnessDown exec --no-startup-id brightnessctl --quiet set 5%- bindsym XF86MonBrightnessDown exec --no-startup-id brightnessctl --quiet set 5%-
# launcher float # Authy 2FA window
for_window [title=".*swayapplauncher.*"] floating enable
for_window [title="^Authy$"] floating enable for_window [title="^Authy$"] floating enable
# EstEID
for_window [class="chrome-token-signing"] floating enable for_window [class="chrome-token-signing"] floating enable
# Launcher
for_window [class="Rofi"] floating enable for_window [class="Rofi"] floating enable
# screenshots # screenshots
bindsym Print exec grim $(xdg-user-dir PICTURES)/$(date +'screenshot_%Y-%m-%d-%H%M%S_grim.png') bindsym Print exec ~/.bin/wscreenshot.py
bindsym Print+Shift exec slurp | grim -g - $(xdg-user-dir PICTURES)/$(date +'screenshot_%Y-%m-%d-%H%M%S_grim.png') bindsym Print+Shift exec ~/.bin/wscreenshot.py --region
bindsym Print+Alt exec ~/.bin/wscreenshot.py --window
# media keys # media keys
bindsym XF86AudioPlay exec playerctl play bindsym XF86AudioPlay exec playerctl play
@ -273,7 +256,6 @@ bindsym XF86AudioPrev exec playerctl previous
# #
# Read `man 5 sway-bar` for more information about this section. # Read `man 5 sway-bar` for more information about this section.
bar { bar {
#swaybar_command /home/arti/code/sway_tray/build/swaybar/swaybar
position top position top
# When the status_command prints a new line to stdout, swaybar updates. # When the status_command prints a new line to stdout, swaybar updates.
@ -287,6 +269,8 @@ bar {
} }
} }
# Use US keyboard with Estonian letters
# map Caps Lock to Esc key
input * { input * {
xkb_layout ee,ee xkb_layout ee,ee
xkb_variant us, xkb_variant us,
@ -295,12 +279,14 @@ input * {
tap enabled tap enabled
} }
# Work mouse
input 1133:4123:Logitech_M705 { input 1133:4123:Logitech_M705 {
pointer_accel -0.5 pointer_accel -0.5
natural_scroll disabled natural_scroll disabled
accel_profile adaptive accel_profile adaptive
} }
# T480s laptop
input 1267:32:Elan_Touchpad { input 1267:32:Elan_Touchpad {
pointer_accel 0.1 pointer_accel 0.1
natural_scroll enabled natural_scroll enabled

Loading…
Cancel
Save