mirror of
https://github.com/ItsDrike/dotfiles.git
synced 2024-11-10 02:39:40 +00:00
Merge branch 'arch' into gentoo
This commit is contained in:
commit
58645dcdb2
|
@ -1,11 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
readonly PREVIEW_ID="preview"
|
||||
|
||||
printf '{"action": "add", "identifier": "%s", "x": %d, "y": %d, "width": %d, "height": %d, "scaler": "contain", "scaling_position_x": 0.5, "scaling_position_y": 0.5, "path": "%s"}\n' \
|
||||
"$PREVIEW_ID" "$2" "$3" "$4" "$5" "$1" > "$FIFO_UEBERZUG"
|
||||
|
||||
#declare -p -A cmd=([action]=add [identifier]="$PREVIEW_ID" \
|
||||
# [x]="$2" [y]="$3" [max_width]="$4" [max_height]="$5" \
|
||||
# [path]="$1") > "$FIFO_UEBERZUG"
|
||||
path="$1"
|
||||
x="$2"
|
||||
y="$3"
|
||||
width="$4"
|
||||
height="$5"
|
||||
PREVIEW_ID="preview"
|
||||
|
||||
if [ -n "$FIFO_UEBERZUG" ]; then
|
||||
printf '{"action": "add", "identifier": "%s", "x": %d, "y": %d, "width": %d, "height": %d, "scaler": "contain", "scaling_position_x": 0.5, "scaling_position_y": 0.5, "path": "%s"}\n' \
|
||||
"$PREVIEW_ID" "$x" "$y" "$width" "$height" "$path" > "$FIFO_UEBERZUG"
|
||||
else
|
||||
# Ueberzug isn't avialable, try to use pixterm
|
||||
if command -v pixterm > /dev/null; then
|
||||
pixterm -s 2 -tr "$x" -tc "$width" "$path"
|
||||
else
|
||||
>&2 echo "ueberzug not running, pixterm fallback not found!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
#!/bin/sh
|
||||
# This script handles showing file-previews within lf.
|
||||
|
||||
# It can also show image previews using ueberzug, however
|
||||
# that requires lf to be start with a script that also starts
|
||||
# that requires lf to be started with a script that also starts
|
||||
# ueberzug alongside of it.
|
||||
# (In my dotfiles, this script is in '~/.local/bin/scripts/lfu')
|
||||
# Alternatively, we could also handle ANSI previews with pixterms
|
||||
# this will be in a pretty low quiality, but it will work without
|
||||
# ueberzug. To enable this, change PIXTERM_ENABLED to 1.
|
||||
# if both ueberzug and pixterm are enabled, ueberzug takes precedence.
|
||||
PIXTERM_ENABLED=1
|
||||
|
||||
run_cmd() {
|
||||
# Try to run given command, if it is installed.
|
||||
|
@ -77,7 +83,8 @@ media_handle() {
|
|||
file="$1"
|
||||
shift
|
||||
|
||||
# Set ENABLED=1 if ueberzug is enabled
|
||||
# Set ENABLED=1 if ueberzug or pixterm is enabled
|
||||
command -v pixterm > /dev/null && [ "$PIXTERM_ENABLED" = 1 ] && ENABLED=1
|
||||
[ -n "$FIFO_UEBERZUG" ] && [ -f "$draw_script" ] && ENABLED=1
|
||||
|
||||
case "$file" in
|
||||
|
@ -85,7 +92,7 @@ media_handle() {
|
|||
if [ -n "$ENABLED" ]; then
|
||||
draw_image $draw_script "$file"
|
||||
else
|
||||
echo "@@PREVIEW FALLBACK: Using mediainfo, ueberzug isn't aviable."
|
||||
echo "@@PREVIEW FALLBACK: Using mediainfo, ueberzug isn't available."
|
||||
run_cmd mediainfo "$file"
|
||||
fi
|
||||
;;
|
||||
|
|
|
@ -217,7 +217,6 @@ alias path='echo -e ${PATH//:/\\n}' # Print each PATH entry on a separate line
|
|||
alias unsudo='sudo -k' # Reset sudo timeout (sudo will require password)
|
||||
alias vimwiki='vim -c VimwikiIndex' # Open vimwiki index
|
||||
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
||||
alias colors-256='curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash' # Show color table
|
||||
alias tty-clock='tty-clock -Ssc' # Terminal clock screensaver
|
||||
alias rick='curl -s -L https://raw.githubusercontent.com/ItsDrike/rickrollrc/master/roll.sh| bash' # Terminal rickroll
|
||||
|
||||
|
|
|
@ -22,9 +22,12 @@ dunst &
|
|||
nm-applet &
|
||||
|
||||
# Run trayer-srg for systemtray bar
|
||||
# if installed normally, use `trayer`, not `trayer-srg` command
|
||||
# if installed normally, command will be `trayer`, not `trayer-srg` command
|
||||
trayer --monitor 0 --edge top --align right --widthtype request --padding 0 --transparent true --tint 0x282c34 --alpha 0 --height 23 &
|
||||
|
||||
# Start flameshot in background
|
||||
flameshot &
|
||||
|
||||
# AppArmor notifications
|
||||
aa-notify -p &
|
||||
|
||||
|
|
|
@ -120,6 +120,7 @@ myKeys =
|
|||
, ("M-S-<Print>", spawn "flameshot screen -c")
|
||||
, ("C-<Print>", spawn "flameshot full -p ~/Pictures/Screenshots")
|
||||
, ("C-S-<Print>", spawn "flameshot full -c")
|
||||
, ("C-M-<Print>", spawn "flameshot launcher")
|
||||
|
||||
-- Script shortcuts
|
||||
, ("M-S-p", spawn "setbg ~/Pictures/Wallpapers/Active") -- Set random background
|
||||
|
@ -178,16 +179,16 @@ myKeys =
|
|||
, ("M-M1-k", sendMessage MirrorExpand) -- Expand vert window width
|
||||
|
||||
-- Multimedia keys
|
||||
, ("<XF86AudioMute>", spawn "amixer set Master toggle")
|
||||
, ("<XF86AudioLowerVolume>", spawn "amixer set Master 5%- unmute")
|
||||
, ("<XF86AudioRaiseVolume>", spawn "amixer set Master 5%+ unmute")
|
||||
, ("<XF86MonBrightnessUp>", spawn "brightness + 10 %")
|
||||
, ("<XF86MonBrightnessDown>", spawn "brightness - 10 %")
|
||||
, ("<XF86AudioMute>", spawn "pulsemixer --toggle-mute")
|
||||
, ("<XF86AudioLowerVolume>", spawn "pulsemixer --change-volume -5")
|
||||
, ("<XF86AudioRaiseVolume>", spawn "pulsemixer --change-volume +5")
|
||||
, ("<XF86MonBrightnessUp>", spawn "brightness + 5 %")
|
||||
, ("<XF86MonBrightnessDown>", spawn "brightness - 5 %")
|
||||
-- Map media keys to meta + arrows for keyboards without special keys
|
||||
, ("M-<Down>", spawn "amixer set Master 5%- unmute")
|
||||
, ("M-<Up>", spawn "amixer set Master 5%+ unmute")
|
||||
, ("M-<Right>", spawn "brightness + 10 %")
|
||||
, ("M-<Left>", spawn "brightness - 10 %")
|
||||
, ("M-<Down>", spawn "pulsemixer --change-volume -5")
|
||||
, ("M-<Up>", spawn "pulsemixer --change-volume +5")
|
||||
, ("M-<Right>", spawn "brightness + 5 %")
|
||||
, ("M-<Left>", spawn "brightness - 5 %")
|
||||
]
|
||||
where nonNSP = WSIs (return (\ws -> W.tag ws /= "NSP"))
|
||||
nonEmptyNonNSP = WSIs (return (\ws -> isJust (W.stack ws) && W.tag ws /= "NSP"))
|
||||
|
@ -315,6 +316,7 @@ myManageHook = composeAll
|
|||
-- auto-shift applications to their respecitve workspaces
|
||||
, className =? "discord" --> doShift ( myWorkspaces !! 3 )
|
||||
, className =? "Code" --> doShift ( myWorkspaces !! 0 )
|
||||
, className =? "Stremio" --> doShift ( myWorkspaces !! 5 )
|
||||
, title =? "Mozilla Firefox" --> doShift ( myWorkspaces !! 1 )
|
||||
]
|
||||
|
||||
|
|
102
home/.local/bin/scripts/colors-256
Executable file
102
home/.local/bin/scripts/colors-256
Executable file
|
@ -0,0 +1,102 @@
|
|||
#!/bin/bash
|
||||
|
||||
# # Print out 256 colors, with each number printed in its corresponding colour
|
||||
#
|
||||
# This file is uploaded on <https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/>
|
||||
# It was originally intended to be used as an alias that curled this URL and piped it into bash, however
|
||||
# this is very unsafe as the owner can change the content of this gist at his convenience, meaning it was
|
||||
# a potential security vulnerability. This is a script version of this alias to avoid this issue.
|
||||
#
|
||||
# The copyright for this file belongs to the original author: Tom Hale, 2016
|
||||
# This file was released under MIT license
|
||||
|
||||
set -eu # Fail on errors or undeclared variables
|
||||
|
||||
printable_colours=256
|
||||
|
||||
# Return a colour that contrasts with the given colour
|
||||
# Bash only does integer division, so keep it integral
|
||||
function contrast_colour {
|
||||
local r g b luminance
|
||||
colour="$1"
|
||||
|
||||
if (( colour < 16 )); then # Initial 16 ANSI colours
|
||||
(( colour == 0 )) && printf "15" || printf "0"
|
||||
return
|
||||
fi
|
||||
|
||||
# Greyscale # rgb_R = rgb_G = rgb_B = (number - 232) * 10 + 8
|
||||
if (( colour > 231 )); then # Greyscale ramp
|
||||
(( colour < 244 )) && printf "15" || printf "0"
|
||||
return
|
||||
fi
|
||||
|
||||
# All other colours:
|
||||
# 6x6x6 colour cube = 16 + 36*R + 6*G + B # Where RGB are [0..5]
|
||||
# See http://stackoverflow.com/a/27165165/5353461
|
||||
|
||||
# r=$(( (colour-16) / 36 ))
|
||||
g=$(( ((colour-16) % 36) / 6 ))
|
||||
# b=$(( (colour-16) % 6 ))
|
||||
|
||||
# If luminance is bright, print number in black, white otherwise.
|
||||
# Green contributes 587/1000 to human perceived luminance - ITU R-REC-BT.601
|
||||
(( g > 2)) && printf "0" || printf "15"
|
||||
return
|
||||
|
||||
# Uncomment the below for more precise luminance calculations
|
||||
|
||||
# # Calculate percieved brightness
|
||||
# # See https://www.w3.org/TR/AERT#color-contrast
|
||||
# # and http://www.itu.int/rec/R-REC-BT.601
|
||||
# # Luminance is in range 0..5000 as each value is 0..5
|
||||
# luminance=$(( (r * 299) + (g * 587) + (b * 114) ))
|
||||
# (( $luminance > 2500 )) && printf "0" || printf "15"
|
||||
}
|
||||
|
||||
# Print a coloured block with the number of that colour
|
||||
function print_colour {
|
||||
local colour="$1" contrast
|
||||
contrast=$(contrast_colour "$1")
|
||||
printf "\e[48;5;%sm" "$colour" # Start block of colour
|
||||
printf "\e[38;5;%sm%3d" "$contrast" "$colour" # In contrast, print number
|
||||
printf "\e[0m " # Reset colour
|
||||
}
|
||||
|
||||
# Starting at $1, print a run of $2 colours
|
||||
function print_run {
|
||||
local i
|
||||
for (( i = "$1"; i < "$1" + "$2" && i < printable_colours; i++ )) do
|
||||
print_colour "$i"
|
||||
done
|
||||
printf " "
|
||||
}
|
||||
|
||||
# Print blocks of colours
|
||||
function print_blocks {
|
||||
local start="$1" i
|
||||
local end="$2" # inclusive
|
||||
local block_cols="$3"
|
||||
local block_rows="$4"
|
||||
local blocks_per_line="$5"
|
||||
local block_length=$((block_cols * block_rows))
|
||||
|
||||
# Print sets of blocks
|
||||
for (( i = start; i <= end; i += (blocks_per_line-1) * block_length )) do
|
||||
printf "\n" # Space before each set of blocks
|
||||
# For each block row
|
||||
for (( row = 0; row < block_rows; row++ )) do
|
||||
# Print block columns for all blocks on the line
|
||||
for (( block = 0; block < blocks_per_line; block++ )) do
|
||||
print_run $(( i + (block * block_length) )) "$block_cols"
|
||||
done
|
||||
(( i += block_cols )) # Prepare to print the next row
|
||||
printf "\n"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
print_run 0 16 # The first 16 colours are spread over the whole spectrum
|
||||
printf "\n"
|
||||
print_blocks 16 231 6 6 3 # 6x6x6 colour cube between 16 and 231 inclusive
|
||||
print_blocks 232 255 12 2 1 # Not 50, but 24 Shades of Grey
|
0
home/.local/share/xmonad/.keep
Normal file
0
home/.local/share/xmonad/.keep
Normal file
Loading…
Reference in a new issue