i3: Add i3 config
This commit is contained in:
parent
41072b5554
commit
a8d1acc78d
7 changed files with 498 additions and 0 deletions
20
config/i3/backlight.fish
Executable file
20
config/i3/backlight.fish
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/fish
|
||||
xbacklight $argv[1..-1]
|
||||
|
||||
set file /tmp/notify-brightness.id
|
||||
set age (find "$file" -cmin -0.2)
|
||||
|
||||
set brightness (xbacklight -get)
|
||||
set bar (seq -s "─" 0 (math $brightness / 3) | tr -d '[:digit:]')
|
||||
|
||||
set percentage (printf '%44s%d%%' '' "$brightness")
|
||||
set body "$percentage\n $bar"
|
||||
|
||||
if [ -n "$age" ]
|
||||
dunstify -r (cat "$file") "Brightness" "$body"
|
||||
touch "$file"
|
||||
else
|
||||
set id (dunstify -p "Brightness" "$body")
|
||||
echo $id > "$file"
|
||||
chmod 600 "$file"
|
||||
end
|
232
config/i3/config
Normal file
232
config/i3/config
Normal file
|
@ -0,0 +1,232 @@
|
|||
# i3 config file (v4)
|
||||
#
|
||||
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
|
||||
exec --no-startup-id xrandr --dpi 192
|
||||
exec --no-startup-id compton
|
||||
|
||||
set $mod Mod4
|
||||
|
||||
# Font for window titles. Will also be used by the bar unless a different font
|
||||
# is used in the bar {} block below.
|
||||
font pango:Ubuntu, Icons 10
|
||||
|
||||
# Use Mouse+$mod to drag floating windows to their wanted position
|
||||
floating_modifier $mod
|
||||
|
||||
# start a terminal
|
||||
bindsym $mod+Return exec --no-startup-id i3-sensible-terminal && ~/.config/i3/cursor.sh
|
||||
bindsym $mod+Shift+Return exec --no-startup-id emacsclient -nc
|
||||
|
||||
# kill focused window
|
||||
bindsym $mod+Shift+q exec --no-startup-id ~/.config/i3/cursor.sh kill
|
||||
|
||||
# start dmenu (a program launcher)
|
||||
bindsym $mod+space exec --no-startup-id i3-dmenu-desktop --dmenu='rofi -dmenu -i -font "Ubuntu 20"'
|
||||
|
||||
# lock the desktop
|
||||
bindsym $mod+l exec --no-startup-id dm-tool lock
|
||||
|
||||
# alternatively, you can use the cursor keys:
|
||||
bindsym $mod+Left exec --no-startup-id ~/.config/i3/cursor.sh focus left
|
||||
bindsym $mod+Down exec --no-startup-id ~/.config/i3/cursor.sh focus down
|
||||
bindsym $mod+Up exec --no-startup-id ~/.config/i3/cursor.sh focus up
|
||||
bindsym $mod+Right exec --no-startup-id ~/.config/i3/cursor.sh focus right
|
||||
|
||||
# move focused window
|
||||
bindsym $mod+Shift+j exec --no-startup-id ~/.config/i3/cursor.sh move left
|
||||
bindsym $mod+Shift+k exec --no-startup-id ~/.config/i3/cursor.sh move down
|
||||
bindsym $mod+Shift+l exec --no-startup-id ~/.config/i3/cursor.sh move up
|
||||
bindsym $mod+Shift+semicolon exec --no-startup-id ~/.config/i3/cursor.sh move right
|
||||
|
||||
# alternatively, you can use the cursor keys:
|
||||
bindsym $mod+Shift+Left exec --no-startup-id ~/.config/i3/cursor.sh move left
|
||||
bindsym $mod+Shift+Down exec --no-startup-id ~/.config/i3/cursor.sh move down
|
||||
bindsym $mod+Shift+Up exec --no-startup-id ~/.config/i3/cursor.sh move up
|
||||
bindsym $mod+Shift+Right exec --no-startup-id ~/.config/i3/cursor.sh move right
|
||||
|
||||
# split in horizontal orientation
|
||||
bindsym $mod+h split h
|
||||
|
||||
# split in vertical orientation
|
||||
bindsym $mod+v split v
|
||||
|
||||
# enter fullscreen mode for the focused container
|
||||
bindsym $mod+f fullscreen toggle
|
||||
|
||||
# change container layout (stacked, tabbed, toggle split)
|
||||
bindsym $mod+s layout stacking
|
||||
bindsym $mod+w layout tabbed
|
||||
bindsym $mod+e layout toggle split
|
||||
|
||||
# toggle tiling / floating
|
||||
bindsym $mod+Shift+space floating toggle
|
||||
|
||||
# change focus between tiling / floating windows
|
||||
# bindsym $mod+space focus mode_toggle
|
||||
|
||||
# focus the parent container
|
||||
bindsym $mod+a focus parent
|
||||
|
||||
# focus the child container
|
||||
#bindsym $mod+d focus child
|
||||
|
||||
# switch to workspace
|
||||
bindsym $mod+1 workspace number 1
|
||||
bindsym $mod+2 workspace number 2
|
||||
bindsym $mod+3 workspace number 3
|
||||
bindsym $mod+4 workspace number 4
|
||||
bindsym $mod+5 workspace number 5
|
||||
bindsym $mod+6 workspace number 6
|
||||
bindsym $mod+7 workspace number 7
|
||||
bindsym $mod+8 workspace number 8
|
||||
bindsym $mod+9 workspace number 9
|
||||
bindsym $mod+0 workspace number 10
|
||||
bindsym $mod+Ctrl+1 workspace number 11
|
||||
bindsym $mod+Ctrl+2 workspace number 12
|
||||
bindsym $mod+Ctrl+3 workspace number 13
|
||||
bindsym $mod+Ctrl+4 workspace number 14
|
||||
bindsym $mod+Ctrl+5 workspace number 15
|
||||
bindsym $mod+Ctrl+6 workspace number 16
|
||||
bindsym $mod+Ctrl+7 workspace number 17
|
||||
bindsym $mod+Ctrl+8 workspace number 18
|
||||
bindsym $mod+Ctrl+9 workspace number 19
|
||||
bindsym $mod+Ctrl+0 workspace number 20
|
||||
|
||||
# scroll though workspaces
|
||||
bindsym $mod+Tab exec --no-startup-id ~/.config/i3/cursor.sh workspace next
|
||||
bindsym $mod+Shift+Tab exec --no-startup-id ~/.config/i3/cursor.sh workspace previous
|
||||
|
||||
# move focused container to workspace
|
||||
bindsym $mod+Shift+1 move container to workspace number 1
|
||||
bindsym $mod+Shift+2 move container to workspace number 2
|
||||
bindsym $mod+Shift+3 move container to workspace number 3
|
||||
bindsym $mod+Shift+4 move container to workspace number 4
|
||||
bindsym $mod+Shift+5 move container to workspace number 5
|
||||
bindsym $mod+Shift+6 move container to workspace number 6
|
||||
bindsym $mod+Shift+7 move container to workspace number 7
|
||||
bindsym $mod+Shift+8 move container to workspace number 8
|
||||
bindsym $mod+Shift+9 move container to workspace number 9
|
||||
bindsym $mod+Shift+0 move container to workspace number 10
|
||||
bindsym $mod+Ctrl+Shift+1 move container to workspace number 11
|
||||
bindsym $mod+Ctrl+Shift+2 move container to workspace number 12
|
||||
bindsym $mod+Ctrl+Shift+3 move container to workspace number 13
|
||||
bindsym $mod+Ctrl+Shift+4 move container to workspace number 14
|
||||
bindsym $mod+Ctrl+Shift+5 move container to workspace number 15
|
||||
bindsym $mod+Ctrl+Shift+6 move container to workspace number 16
|
||||
bindsym $mod+Ctrl+Shift+7 move container to workspace number 17
|
||||
bindsym $mod+Ctrl+Shift+8 move container to workspace number 18
|
||||
bindsym $mod+Ctrl+Shift+9 move container to workspace number 19
|
||||
bindsym $mod+Ctrl+Shift+0 move container to workspace number 20
|
||||
|
||||
# move focused container to the next display
|
||||
bindsym $mod+m exec --no-startup-id ~/.config/i3/cycle-monitor.py
|
||||
|
||||
# reload the configuration file
|
||||
bindsym $mod+Shift+c reload
|
||||
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
|
||||
bindsym $mod+Shift+r restart
|
||||
# exit i3 (logs you out of your X session)
|
||||
bindsym $mod+Shift+e exec --no-startup-id "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
|
||||
|
||||
# Media player controls
|
||||
bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause
|
||||
bindsym XF86AudioNext exec --no-startup-id playerctl next
|
||||
bindsym XF86AudioPrev exec --no-startup-id playerctl previous
|
||||
|
||||
bindsym XF86MonBrightnessUp exec --no-startup-id ~/.config/i3/backlight.fish -inc 5
|
||||
bindsym XF86MonBrightnessDown exec --no-startup-id ~/.config/i3/backlight.fish -dec 5
|
||||
bindsym Shift+XF86MonBrightnessUp exec --no-startup-id ~/.config/i3/backlight.fish -inc 2
|
||||
bindsym Shift+XF86MonBrightnessDown exec --no-startup-id ~/.config/i3/backlight.fish -dec 2
|
||||
|
||||
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5%
|
||||
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5%
|
||||
bindsym Shift+XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +2%
|
||||
bindsym Shift+XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -2%
|
||||
|
||||
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle
|
||||
bindsym Shift+XF86AudioMute exec --no-startup-id pavucontrol
|
||||
|
||||
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute 1 toggle
|
||||
|
||||
bindsym XF86Calculator exec --no-startup-id gnome-calculator
|
||||
bindsym Print exec --no-startup-id escrotum -sC && notify-send --urgency=low "Screenshot taken"
|
||||
bindsym $mod+Print exec --no-startup-id $HOME/.config/i3/screenrecord.sh
|
||||
|
||||
bindsym $mod+t exec --no-startup-id gnome-terminal -t i3tree -e 'bash -c "perl -Mutf8 -CS $(which i3tree) | less"'
|
||||
|
||||
for_window [title="^i3tree$"] floating enable
|
||||
for_window [class="^Gpick$"] floating enable
|
||||
for_window [class="^Arandr$"] floating enable
|
||||
for_window [class="^Pavucontrol$"] floating enable
|
||||
for_window [class="^Gnome-calculator$"] floating enable
|
||||
|
||||
# Light theme
|
||||
## class border backgr. text indic. child_border
|
||||
#client.focused #fafafa #607d8b #ffffff #b0bec5 #4db6ac
|
||||
#client.focused_inactive #fafafa #37474f #ffffff #78909c #e0f2f1
|
||||
#client.unfocused #fafafa #37474f #ffffff #78909c #e0f2f1
|
||||
#client.urgent #fafafa #ff5722 #ffffff #ffab91 #bf360c
|
||||
|
||||
# Dark theme
|
||||
# class border backgr. text indic. child_border
|
||||
client.focused #292b2e #607d8b #ffffff #b0bec5 #4db6ac
|
||||
client.focused_inactive #292b2e #37474f #ffffff #78909c #292b2e
|
||||
client.unfocused #292b2e #37474f #ffffff #78909c #292b2e
|
||||
client.urgent #292b2e #ff5722 #ffffff #ffab91 #bf360c
|
||||
|
||||
# resize window (you can also use the mouse for that)
|
||||
mode "resize" {
|
||||
# These bindings trigger as soon as you enter the resize mode
|
||||
bindsym j resize shrink width 10 px or 10 ppt
|
||||
bindsym k resize grow height 10 px or 10 ppt
|
||||
bindsym l resize shrink height 10 px or 10 ppt
|
||||
bindsym semicolon resize grow width 10 px or 10 ppt
|
||||
|
||||
# same bindings, but for the arrow keys
|
||||
bindsym Left resize shrink width 10 px or 10 ppt
|
||||
bindsym Down resize grow height 10 px or 10 ppt
|
||||
bindsym Up resize shrink height 10 px or 10 ppt
|
||||
bindsym Right resize grow width 10 px or 10 ppt
|
||||
|
||||
# back to normal: Enter or Escape
|
||||
bindsym Return mode "default"
|
||||
bindsym Escape mode "default"
|
||||
}
|
||||
|
||||
bindsym $mod+r mode "resize"
|
||||
|
||||
# Start i3bar to display a workspace bar (plus the system information i3status
|
||||
# finds out, if available)
|
||||
bar {
|
||||
status_command i3status
|
||||
tray_output none
|
||||
colors {
|
||||
# Light theme
|
||||
#background #fafafa
|
||||
#statusline #212121
|
||||
#separator #424242
|
||||
|
||||
#focused_workspace #fafafa #009688 #ffffff
|
||||
#inactive_workspace #fafafa #fafafa #212121
|
||||
#active_workspace #fafafa #424242 #ffffff
|
||||
#urgent_workspace #fafafa #b71c1c #ffffff
|
||||
#binding_mode #fafafa #b71c1c #ffffff
|
||||
|
||||
# Dark theme
|
||||
background #292b2e
|
||||
statusline #dddddd
|
||||
separator #4a4e54
|
||||
|
||||
focused_workspace #292b2e #009688 #dddddd
|
||||
inactive_workspace #292b2e #292b2e #dddddd
|
||||
active_workspace #292b2e #424242 #dddddd
|
||||
urgent_workspace #292b2e #b71c1c #dddddd
|
||||
binding_mode #292b2e #b71c1c #dddddd
|
||||
}
|
||||
}
|
||||
|
||||
for_window [class="^.*"] border pixel 2
|
||||
gaps inner 5
|
||||
|
||||
exec_always --no-startup-id feh /home/sijmen/Pictures/uncharted4.jpg --bg-fill
|
||||
exec_always --no-startup-id sh -c "PYTHONUNBUFFERED=1 python $HOME/.config/i3/icons.py 2>&1 > /tmp/icons.log"
|
18
config/i3/cursor.sh
Executable file
18
config/i3/cursor.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
# Taken from http://pushl.net/blog/18/
|
||||
|
||||
eval i3-msg $*
|
||||
HERE=`xdotool getwindowfocus`
|
||||
|
||||
ULX=`xwininfo -id $HERE | grep " Absolute upper-left X:" | awk '{print $4}'`
|
||||
ULY=`xwininfo -id $HERE | grep " Absolute upper-left Y:" | awk '{print $4}'`
|
||||
|
||||
# If there is no window, ULX == 1 and ULY == 1.
|
||||
if [ $ULX != "-1" -o $ULY != "-1" ]; then
|
||||
eval `xdotool getwindowgeometry --shell $HERE`
|
||||
|
||||
NX=`expr $WIDTH / 2`
|
||||
NY=`expr $HEIGHT / 2`
|
||||
|
||||
xdotool mousemove --window $WINDOW $NX $NY
|
||||
fi
|
16
config/i3/cycle-monitor.py
Executable file
16
config/i3/cycle-monitor.py
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env python
|
||||
# Source: https://gist.github.com/justbuchanan/00b8d4aac604fa6ab41b7c5acae71ee8
|
||||
import i3
|
||||
|
||||
outputs = i3.get_outputs()
|
||||
workspaces = i3.get_workspaces()
|
||||
|
||||
# figure out what is on, and what is currently on your screen.
|
||||
workspace = list(filter(lambda s: s['focused']==True, workspaces))
|
||||
output = list(filter(lambda s: s['active']==True, outputs))
|
||||
|
||||
# figure out the other workspace name
|
||||
other_workspace = list(filter(lambda s: s['name']!=workspace[0]['output'], output))
|
||||
|
||||
# send current to the no-active one
|
||||
i3.command('move', 'workspace to output '+other_workspace[0]['name'])
|
50
config/i3/hotplug.fish
Executable file
50
config/i3/hotplug.fish
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/fish
|
||||
|
||||
## DOES NOT WORK YET :(
|
||||
|
||||
sleep 2
|
||||
|
||||
set dp1 (cat /sys/class/drm/card0-DP-1/status)
|
||||
set dp2 (cat /sys/class/drm/card0-DP-2/status)
|
||||
set hdmi1 (cat /sys/class/drm/card0-HDMI-A-1/status)
|
||||
set hdmi2 (cat /sys/class/drm/card0-HDMI-A-2/status)
|
||||
|
||||
set rightof "eDP1"
|
||||
|
||||
if [ $dp1 = "connected" ]
|
||||
xrandr --output DP1 --right-of $rightof --auto
|
||||
set rightof "DP1"
|
||||
notify-send --urgency=low -t 2000 "Graphics Update" "USB-C display plugged in"
|
||||
else
|
||||
xrandr --output DP1 --off
|
||||
end
|
||||
|
||||
if [ $dp2 = "connected" ]
|
||||
xrandr --output DP2 --right-of $rightof --auto
|
||||
set rightof "DP2"
|
||||
notify-send --urgency=low -t 2000 "Graphics Update" "USB-C display plugged in"
|
||||
else
|
||||
xrandr --output DP2 --off
|
||||
end
|
||||
|
||||
if [ $hdmi1 = "connected" ]
|
||||
xrandr --output HDMI1 --right-of $rightof --auto
|
||||
set rightof "HDMI1"
|
||||
notify-send --urgency=low -t 2000 "Graphics Update" "USB-C display plugged in"
|
||||
else
|
||||
xrandr --output HDMI1 --off
|
||||
end
|
||||
|
||||
if [ $hdmi2 = "connected" ]
|
||||
notify-send --urgency=low -t 2000 "Graphics Update" "HDMI display plugged in"
|
||||
|
||||
xrandr --output HDMI2 --right-of $rightof --auto
|
||||
set rightof "HDMI2"
|
||||
|
||||
set identifier (parse-edid < /sys/class/drm/card0-HDMI-A-2/edid | grep Identifier | cut -d' ' -f 2-)
|
||||
if [ $identifier = '"LG ULTRAWIDE"' ]
|
||||
xrandr --output HDMI2 --scale 2x2
|
||||
end
|
||||
else
|
||||
xrandr --output HDMI2 --off
|
||||
end
|
126
config/i3/icons.py
Normal file
126
config/i3/icons.py
Normal file
|
@ -0,0 +1,126 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Taken from https://gist.github.com/bgavran/462c9391a49a835546f9bf9c15ce56f9
|
||||
# and slightly modified by me (https://github.com/SijmenSchoon).
|
||||
#
|
||||
# This script listens for i3 events and updates workspace names to show icons
|
||||
# for running programs. It contains icons for a few programs, but more can
|
||||
# easily be added by inserting them into WINDOW_ICONS below.
|
||||
#
|
||||
# Dependencies
|
||||
# * xorg-xprop - install through system package manager
|
||||
# * i3ipc - install with pip
|
||||
|
||||
|
||||
import i3ipc
|
||||
import subprocess as proc
|
||||
import re
|
||||
|
||||
|
||||
# Add icons here for common programs you use. The keys are the X window class
|
||||
# (WM_CLASS) names and the icons can be any text you want to display. However
|
||||
# most of these are character codes for font awesome:
|
||||
# http://fortawesome.github.io/Font-Awesome/icons/
|
||||
FA_CHROME = "\uf268"
|
||||
FA_CODE = "\uf121"
|
||||
FA_FILE_PDF_O = "\uf1c1"
|
||||
FA_FILE_TEXT_O = "\uf0f6"
|
||||
FA_FILES_O = "\uf0c5"
|
||||
FA_FIREFOX = "\uf269"
|
||||
FA_PICTURE_O = "\uf03e"
|
||||
FA_SPOTIFY = "\uf1bc"
|
||||
FA_TERMINAL = "\uf120"
|
||||
FA_TELEGRAM = "\uf3fe"
|
||||
FA_CUBE = "\uf1b2"
|
||||
FA_PAINT_BRUSH = "\uf1fc"
|
||||
FA_BOOK = "\uf02d"
|
||||
FA_FOLDER = "\uf07c"
|
||||
FA_CALENDAR = "\uf133"
|
||||
FA_VOLUME_UP = "\uf028"
|
||||
|
||||
WINDOW_ICONS = {
|
||||
"Firefox": FA_FIREFOX,
|
||||
"Gnome-terminal": FA_TERMINAL,
|
||||
"chromium": FA_CHROME,
|
||||
"code": FA_CODE,
|
||||
"emacs": FA_CODE,
|
||||
"evince": FA_FILE_PDF_O,
|
||||
"feh": FA_PICTURE_O,
|
||||
"gimp-2.10": FA_PAINT_BRUSH,
|
||||
"gnome-calendar": FA_CALENDAR,
|
||||
"google-chrome": FA_CHROME,
|
||||
"jetbrains-pycharm": FA_CODE,
|
||||
"jetbrains-webstorm": FA_CODE,
|
||||
"libreoffice": FA_FILE_TEXT_O,
|
||||
"mupdf": FA_FILE_PDF_O,
|
||||
"nautilus": FA_FOLDER,
|
||||
"notion-nativefier-102b2f": FA_BOOK,
|
||||
"pulseeffects": FA_VOLUME_UP,
|
||||
"slic3r-prusa3d": FA_CUBE,
|
||||
"spotify": FA_SPOTIFY,
|
||||
"subl": FA_CODE,
|
||||
"subl3": FA_CODE,
|
||||
"telegram-desktop": FA_TELEGRAM,
|
||||
"thunar": FA_FOLDER,
|
||||
"urxvt": FA_TERMINAL,
|
||||
}
|
||||
|
||||
|
||||
i3 = i3ipc.Connection()
|
||||
|
||||
|
||||
def xprop(win_id, property):
|
||||
"""
|
||||
Return an array of the values for the given property from xprop.
|
||||
|
||||
Requires xorg-xprop to be installed.
|
||||
"""
|
||||
try:
|
||||
prop = proc.check_output(['xprop', '-id', str(win_id), property],
|
||||
stderr=proc.DEVNULL)
|
||||
prop = prop.decode('utf-8')
|
||||
return re.findall('"([^"]+)"', prop)
|
||||
except proc.CalledProcessError:
|
||||
print(f"Unable to get property for window '{win_id}'")
|
||||
return None
|
||||
|
||||
|
||||
def icon_for_window(window):
|
||||
classes = xprop(window.window, 'WM_CLASS')
|
||||
if classes:
|
||||
for cls in classes:
|
||||
if cls in WINDOW_ICONS:
|
||||
return WINDOW_ICONS[cls]
|
||||
print('No icon available for window with classes: %s' % str(classes))
|
||||
return '*'
|
||||
|
||||
|
||||
def rename():
|
||||
"""Rename all workspaces based on the present windows."""
|
||||
for workspace in i3.get_tree().workspaces():
|
||||
icons = " ".join(icon_for_window(w) for w in workspace.leaves())
|
||||
|
||||
new_name = f"{workspace.num}"
|
||||
if icons:
|
||||
new_name += f": {icons}"
|
||||
|
||||
i3.command(f'rename workspace "{workspace.name}" to "{new_name}"')
|
||||
|
||||
|
||||
def on_change(i3, e):
|
||||
"""Call rename() on relevant window events."""
|
||||
print(f"{e.change}")
|
||||
if e.change in ['new', 'close', 'move']:
|
||||
rename()
|
||||
|
||||
|
||||
def main():
|
||||
rename()
|
||||
|
||||
i3.on('window', on_change)
|
||||
i3.main()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
36
config/i3/screenrecord.sh
Executable file
36
config/i3/screenrecord.sh
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Originally created by Robin Voetter (https://github.com/Snektron),
|
||||
# then modified by me (https://github.com/SijmenSchoon).
|
||||
|
||||
if [ -f /tmp/screenrecord.pid ]; then
|
||||
pkill -P $(cat "/tmp/screenrecord.pid")
|
||||
exit 0
|
||||
fi
|
||||
|
||||
read -r x y w h < <(slop -f "%x %y %w %h" -q)
|
||||
if [ -z "$x" ]; then
|
||||
echo "Cancelled"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
id=$(notify-send.sh -p -u low "Starting recording in 3 seconds"); sleep 1
|
||||
notify-send.sh -r "$id" -u low "Starting recording in 2 seconds"; sleep 1
|
||||
notify-send.sh -r "$id" -u low -t 500 "Starting recording in 1 seconds"; sleep 1
|
||||
|
||||
{
|
||||
date=$(date '+%Y%M%d-%H%M%S')
|
||||
ffmpeg -video_size "$w"x"$h" \
|
||||
-framerate 30 \
|
||||
-f x11grab \
|
||||
-i :0.0+"$x","$y" \
|
||||
-vf "scale=trunc(iw/4)*2:trunc(ih/4)*2" \
|
||||
-pix_fmt yuv420p \
|
||||
"$HOME/Videos/sr-$date.mp4"
|
||||
|
||||
rm /tmp/screenrecord.pid
|
||||
notify-send.sh -u low "Stopped recording" "Saved recording to ~/Videos/sr-$date.mp4"
|
||||
xclip -sel clip <<< "$HOME/Videos/sr-$date.mp4"
|
||||
} &
|
||||
|
||||
echo "$!" > /tmp/screenrecord.pid
|
Loading…
Reference in a new issue