Add bin directory
This commit is contained in:
4
.bashrc
4
.bashrc
@@ -37,6 +37,8 @@ alias gd='git diff'
|
|||||||
# |_____|_| \_| \_/ |___|_| \_\\___/|_| \_|_| |_|_____|_| \_| |_|
|
# |_____|_| \_| \_/ |___|_| \_\\___/|_| \_|_| |_|_____|_| \_| |_|
|
||||||
#
|
#
|
||||||
|
|
||||||
|
export PATH="$PATH:$HOME/dotfiles/bin"
|
||||||
|
|
||||||
export TERM=alacritty
|
export TERM=alacritty
|
||||||
export EDITOR=nvim
|
export EDITOR=nvim
|
||||||
export VISUAL=nvim
|
export VISUAL=nvim
|
||||||
@@ -44,7 +46,7 @@ export VISUAL=nvim
|
|||||||
# Go ENVs
|
# Go ENVs
|
||||||
export GO111MODULE=auto
|
export GO111MODULE=auto
|
||||||
export GOBIN="$HOME/go/bin"
|
export GOBIN="$HOME/go/bin"
|
||||||
export PATH="$PATH:$HOME/scripts:$GOBIN"
|
export PATH="$PATH:$GOBIN"
|
||||||
|
|
||||||
# Find arch package by binary
|
# Find arch package by binary
|
||||||
source /usr/share/doc/pkgfile/command-not-found.bash
|
source /usr/share/doc/pkgfile/command-not-found.bash
|
||||||
|
|||||||
6
bin/build-go
Executable file
6
bin/build-go
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
GOOS=windows GOARCH=amd64 go build -o "$1_windows.exe"
|
||||||
|
GOOS=linux GOARCH=amd64 go build -o "$1_linux"
|
||||||
|
GOOS=darwin GOARCH=amd64 go build -o "$1_macos"
|
||||||
|
GOOS=darwin GOARCH=arm64 go build -o "$1_macos_arm"
|
||||||
154
bin/grimshot
Executable file
154
bin/grimshot
Executable file
@@ -0,0 +1,154 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
## Grimshot: a helper for screenshots within sway
|
||||||
|
## Requirements:
|
||||||
|
## - `grim`: screenshot utility for wayland
|
||||||
|
## - `slurp`: to select an area
|
||||||
|
## - `swaymsg`: to read properties of current window
|
||||||
|
## - `wl-copy`: clipboard utility
|
||||||
|
## - `jq`: json utility to parse swaymsg output
|
||||||
|
## - `notify-send`: to show notifications
|
||||||
|
## Those are needed to be installed, if unsure, run `grimshot check`
|
||||||
|
##
|
||||||
|
## See `man 1 grimshot` or `grimshot usage` for further details.
|
||||||
|
|
||||||
|
getTargetDirectory() {
|
||||||
|
test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && \
|
||||||
|
. ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
|
||||||
|
|
||||||
|
echo ${XDG_SCREENSHOTS_DIR:-${XDG_PICTURES_DIR:-$HOME}}
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$1" = "--notify" ]; then
|
||||||
|
NOTIFY=yes
|
||||||
|
shift 1
|
||||||
|
else
|
||||||
|
NOTIFY=no
|
||||||
|
fi
|
||||||
|
|
||||||
|
ACTION=${1:-usage}
|
||||||
|
SUBJECT=${2:-screen}
|
||||||
|
FILE=${3:-$(getTargetDirectory)/$(date -Ins).png}
|
||||||
|
|
||||||
|
if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then
|
||||||
|
echo "Usage:"
|
||||||
|
echo " grimshot [--notify] (copy|save) [active|screen|output|area|window] [FILE|-]"
|
||||||
|
echo " grimshot check"
|
||||||
|
echo " grimshot usage"
|
||||||
|
echo ""
|
||||||
|
echo "Commands:"
|
||||||
|
echo " copy: Copy the screenshot data into the clipboard."
|
||||||
|
echo " save: Save the screenshot to a regular file or '-' to pipe to STDOUT."
|
||||||
|
echo " check: Verify if required tools are installed and exit."
|
||||||
|
echo " usage: Show this message and exit."
|
||||||
|
echo ""
|
||||||
|
echo "Targets:"
|
||||||
|
echo " active: Currently active window."
|
||||||
|
echo " screen: All visible outputs."
|
||||||
|
echo " output: Currently active output."
|
||||||
|
echo " area: Manually select a region."
|
||||||
|
echo " window: Manually select a window."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
notify() {
|
||||||
|
notify-send -t 3000 -a grimshot "$@"
|
||||||
|
}
|
||||||
|
notifyOk() {
|
||||||
|
[ "$NOTIFY" = "no" ] && return
|
||||||
|
|
||||||
|
TITLE=${2:-"Screenshot"}
|
||||||
|
MESSAGE=${1:-"OK"}
|
||||||
|
notify "$TITLE" "$MESSAGE"
|
||||||
|
}
|
||||||
|
notifyError() {
|
||||||
|
if [ $NOTIFY = "yes" ]; then
|
||||||
|
TITLE=${2:-"Screenshot"}
|
||||||
|
MESSAGE=${1:-"Error taking screenshot with grim"}
|
||||||
|
notify -u critical "$TITLE" "$MESSAGE"
|
||||||
|
else
|
||||||
|
echo $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
die() {
|
||||||
|
MSG=${1:-Bye}
|
||||||
|
notifyError "Error: $MSG"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
check() {
|
||||||
|
COMMAND=$1
|
||||||
|
if command -v "$COMMAND" > /dev/null 2>&1; then
|
||||||
|
RESULT="OK"
|
||||||
|
else
|
||||||
|
RESULT="NOT FOUND"
|
||||||
|
fi
|
||||||
|
echo " $COMMAND: $RESULT"
|
||||||
|
}
|
||||||
|
|
||||||
|
takeScreenshot() {
|
||||||
|
FILE=$1
|
||||||
|
GEOM=$2
|
||||||
|
OUTPUT=$3
|
||||||
|
if [ ! -z "$OUTPUT" ]; then
|
||||||
|
grim -o "$OUTPUT" "$FILE" || die "Unable to invoke grim"
|
||||||
|
elif [ -z "$GEOM" ]; then
|
||||||
|
grim "$FILE" || die "Unable to invoke grim"
|
||||||
|
else
|
||||||
|
grim -g "$GEOM" "$FILE" || die "Unable to invoke grim"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$ACTION" = "check" ] ; then
|
||||||
|
echo "Checking if required tools are installed. If something is missing, install it to your system and make it available in PATH..."
|
||||||
|
check grim
|
||||||
|
check slurp
|
||||||
|
check swaymsg
|
||||||
|
check wl-copy
|
||||||
|
check jq
|
||||||
|
check notify-send
|
||||||
|
exit
|
||||||
|
elif [ "$SUBJECT" = "area" ] ; then
|
||||||
|
GEOM=$(slurp -d)
|
||||||
|
# Check if user exited slurp without selecting the area
|
||||||
|
if [ -z "$GEOM" ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
WHAT="Area"
|
||||||
|
elif [ "$SUBJECT" = "active" ] ; then
|
||||||
|
FOCUSED=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)')
|
||||||
|
GEOM=$(echo "$FOCUSED" | jq -r '.rect | "\(.x),\(.y) \(.width)x\(.height)"')
|
||||||
|
APP_ID=$(echo "$FOCUSED" | jq -r '.app_id')
|
||||||
|
WHAT="$APP_ID window"
|
||||||
|
elif [ "$SUBJECT" = "screen" ] ; then
|
||||||
|
GEOM=""
|
||||||
|
WHAT="Screen"
|
||||||
|
elif [ "$SUBJECT" = "output" ] ; then
|
||||||
|
GEOM=""
|
||||||
|
OUTPUT=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused)' | jq -r '.name')
|
||||||
|
WHAT="$OUTPUT"
|
||||||
|
elif [ "$SUBJECT" = "window" ] ; then
|
||||||
|
GEOM=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)
|
||||||
|
# Check if user exited slurp without selecting the area
|
||||||
|
if [ -z "$GEOM" ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
WHAT="Window"
|
||||||
|
else
|
||||||
|
die "Unknown subject to take a screen shot from" "$SUBJECT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$ACTION" = "copy" ] ; then
|
||||||
|
takeScreenshot - "$GEOM" "$OUTPUT" | wl-copy --type image/png || die "Clipboard error"
|
||||||
|
notifyOk "$WHAT copied to buffer"
|
||||||
|
else
|
||||||
|
if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then
|
||||||
|
TITLE="Screenshot of $SUBJECT"
|
||||||
|
MESSAGE=$(basename "$FILE")
|
||||||
|
notifyOk "$MESSAGE" "$TITLE"
|
||||||
|
echo $FILE
|
||||||
|
else
|
||||||
|
notifyError "Error taking screenshot with grim"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
69
bin/inactive-windows-transparency.py
Executable file
69
bin/inactive-windows-transparency.py
Executable file
@@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
# This script requires i3ipc-python package (install it from a system package manager
|
||||||
|
# or pip).
|
||||||
|
# It makes inactive windows transparent. Use `transparency_val` variable to control
|
||||||
|
# transparency strength in range of 0…1 or use the command line argument -o.
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import i3ipc
|
||||||
|
import signal
|
||||||
|
import sys
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
|
def on_window_focus(inactive_opacity, ipc, event):
|
||||||
|
global prev_focused
|
||||||
|
global prev_workspace
|
||||||
|
|
||||||
|
focused_workspace = ipc.get_tree().find_focused()
|
||||||
|
|
||||||
|
if focused_workspace == None:
|
||||||
|
return
|
||||||
|
|
||||||
|
focused = event.container
|
||||||
|
workspace = focused_workspace.workspace().num
|
||||||
|
|
||||||
|
if focused.id != prev_focused.id: # https://github.com/swaywm/sway/issues/2859
|
||||||
|
focused.command("opacity 1")
|
||||||
|
if workspace == prev_workspace:
|
||||||
|
prev_focused.command("opacity " + inactive_opacity)
|
||||||
|
prev_focused = focused
|
||||||
|
prev_workspace = workspace
|
||||||
|
|
||||||
|
|
||||||
|
def remove_opacity(ipc):
|
||||||
|
for workspace in ipc.get_tree().workspaces():
|
||||||
|
for w in workspace:
|
||||||
|
w.command("opacity 1")
|
||||||
|
ipc.main_quit()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
transparency_val = "0.80"
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="This script allows you to set the transparency of unfocused windows in sway."
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--opacity",
|
||||||
|
"-o",
|
||||||
|
type=str,
|
||||||
|
default=transparency_val,
|
||||||
|
help="set opacity value in range 0...1",
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
ipc = i3ipc.Connection()
|
||||||
|
prev_focused = None
|
||||||
|
prev_workspace = ipc.get_tree().find_focused().workspace().num
|
||||||
|
|
||||||
|
for window in ipc.get_tree():
|
||||||
|
if window.focused:
|
||||||
|
prev_focused = window
|
||||||
|
else:
|
||||||
|
window.command("opacity " + args.opacity)
|
||||||
|
for sig in [signal.SIGINT, signal.SIGTERM]:
|
||||||
|
signal.signal(sig, lambda signal, frame: remove_opacity(ipc))
|
||||||
|
ipc.on("window::focus", partial(on_window_focus, args.opacity))
|
||||||
|
ipc.main()
|
||||||
7
bin/wlshot
Executable file
7
bin/wlshot
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
action=$1
|
||||||
|
|
||||||
|
path="$HOME/Pictures/Screenshots/Screenshot-$(date +%s%3N).png"
|
||||||
|
|
||||||
|
grimshot $action area $path
|
||||||
17
bin/xshot
Executable file
17
bin/xshot
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
action=$1
|
||||||
|
|
||||||
|
if [ "$action" = "" ] ; then
|
||||||
|
echo "You need to specify the action to use (copy/save)"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
file="$HOME/Pictures/Screenshots/Screenshot-$(date +%s%3N).png"
|
||||||
|
selection=$(hacksaw -f "-i %i -g %g")
|
||||||
|
|
||||||
|
if [ "$action" = "save" ] ; then
|
||||||
|
shotgun $selection -
|
||||||
|
else
|
||||||
|
shotgun $selection - | xclip -t "image/png" -selection clipboard
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user