1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

Merge remote-tracking branch 'origin/master' into surface

This commit is contained in:
Joe Groocock 2018-02-22 13:27:57 +00:00
commit d52ece0b12
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86
10 changed files with 237 additions and 170 deletions

View File

@ -29,7 +29,7 @@ alpha-step = 0.06; # XRender backend: Step size for alpha pictures. Increasin
#inactive-dim-fixed = true; # Do not let dimness adjust based on window opacity.
inactive-opacity-exclude = [ "window_type = 'dock'", "window_type = 'desktop'" ];
blur-background = true; # Blur background of transparent windows.
blur-background-exclude = [ "class_g = 'Peek'", "class_g = 'Onboard'" ];
blur-background-exclude = [ "class_g = 'Peek'", "class_g = 'Onboard'", "class_g = 'slop'" ];
blur-background-frame = false; # Blur background of opaque windows with transparent
# frames as well.
blur-background-fixed = true; # Do not let blur radius adjust based on window opacity.

View File

@ -1 +1,2 @@
.idea/
cmake-build-*/

View File

@ -41,8 +41,7 @@ separator_block_width=12
#interval=persist
[volume]
instance=Master
interval=10
interval=persist
signal=10
[separator]
@ -63,7 +62,7 @@ signal=5
[cpu_usage]
label=
interval=5
interval=persist
[separator]

View File

@ -1,53 +1,31 @@
#!/usr/bin/perl
#
# Copyright 2014 Pierre Mavro <deimos@deimos.fr>
# Copyright 2014 Vivien Didelot <vivien@didelot.org>
# Copyright 2014 Andreas Guldstrand <andreas.guldstrand@gmail.com>
#
# Licensed under the terms of the GNU GPL v3, or any later version.
#!/bin/bash
# by Paul Colby (http://colby.id.au), no rights reserved ;)
# https://github.com/Leo-G/DevopsWiki/wiki/How-Linux-CPU-Usage-Time-and-Percentage-is-calculated
use strict;
use warnings;
use utf8;
use Getopt::Long;
PREV_TOTAL=0
PREV_IDLE=0
# default values
my $t_warn = 50;
my $t_crit = 80;
my $cpu_usage = -1;
while true; do
# Get the total CPU statistics, discarding the 'cpu ' prefix.
CPU=(`sed -n 's/^cpu\s//p' /proc/stat`)
IDLE=${CPU[3]} # Just the idle CPU time.
sub help {
print "Usage: cpu_usage [-w <warning>] [-c <critical>]\n";
print "-w <percent>: warning threshold to become yellow\n";
print "-c <percent>: critical threshold to become red\n";
exit 0;
}
# Calculate the total CPU time.
TOTAL=0
for VALUE in "${CPU[@]}"; do
let "TOTAL=$TOTAL+$VALUE"
done
GetOptions("help|h" => \&help,
"w=i" => \$t_warn,
"c=i" => \$t_crit);
# Calculate the CPU usage since we last checked.
let "DIFF_IDLE=$IDLE-$PREV_IDLE"
let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL"
let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10"
echo -e "$DIFF_USAGE%\n$DIFF_USAGE%"
# Get CPU usage
$ENV{LC_ALL}="en_US"; # if mpstat is not run under en_US locale, things may break, so make sure it is
open (MPSTAT, 'mpstat 1 1 |') or die 'Cannot run mpstat';
while (<MPSTAT>) {
if (/^.*\s+(\d+\.\d+)\s+$/) {
$cpu_usage = 100 - $1; # 100% - %idle
last;
}
}
close(MPSTAT);
# Remember the total and idle CPU times for the next check.
PREV_TOTAL="$TOTAL"
PREV_IDLE="$IDLE"
#$cpu_usage eq -1 and die 'Can\'t find CPU information';
# Print short_text, full_text
printf "%.0f%%\n"x2, $cpu_usage;
# Print color, if needed
if ($cpu_usage >= $t_crit) {
print "#FF0000\n";
} elsif ($cpu_usage >= $t_warn) {
print "#FFCB00\n";
}
exit 0;
# Wait before checking again.
sleep 1
done

View File

@ -1,93 +1,182 @@
#!/bin/bash
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# Copyright (C) 2014 Alexander Keller <github@nycroth.com>
# Displays the default device, volume, and mute status for i3blocks
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
AUDIO_HIGH_SYMBOL=' '
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
AUDIO_MED_THRESH=59
AUDIO_MED_SYMBOL=' '
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AUDIO_LOW_THRESH=0
AUDIO_LOW_SYMBOL=' '
#------------------------------------------------------------------------
AUDIO_MUTED_SYMBOL='X'
# The second parameter overrides the mixer selection
# For PulseAudio users, use "pulse"
# For Jack/Jack2 users, use "jackplug"
# For ALSA users, you may use "default" for your primary card
# or you may use hw:# where # is the number of the card desired
MIXER="default"
[ -n "$(lsmod | grep pulse)" ] && MIXER="pulse"
[ -n "$(lsmod | grep jack)" ] && MIXER="jackplug"
MIXER="${2:-$MIXER}"
AUDIO_INTERVAL=5
# The instance option sets the control to report and configure
# This defaults to the first control of your selected mixer
# For a list of the available, use `amixer -D $Your_Mixer scontrols`
SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols |
sed -n "s/Simple mixer control '\([A-Za-z ]*\)',0/\1/p" |
head -n1
)}"
DEFAULT_COLOR="#ffffff"
MUTED_COLOR="#a0a0a0"
# The first parameter sets the step to change the volume by (and units to display)
# This may be in in % or dB (eg. 5% or 3dB)
STEP="${1:-2%}"
LONG_FORMAT=0
SHORT_FORMAT=3
USE_PERCENT=0
USE_ALSA_NAME=0
USE_DESCRIPTION=0
SUBSCRIBE=1
#------------------------------------------------------------------------
while getopts F:Sf:padH:M:L:X:T:t:C:c:i:m:s:h opt; do
case "$opt" in
S) SUBSCRIBE=1 ;;
F) LONG_FORMAT="$OPTARG" ;;
f) SHORT_FORMAT="$OPTARG" ;;
p) USE_PERCENT=0 ;;
a) USE_ALSA_NAME=1 ;;
d) USE_DESCRIPTION=1 ;;
H) AUDIO_HIGH_SYMBOL="$OPTARG" ;;
M) AUDIO_MED_SYMBOL="$OPTARG" ;;
L) AUDIO_LOW_SYMBOL="$OPTARG" ;;
X) AUDIO_MUTED_SYMBOL="$OPTARG" ;;
T) AUDIO_MED_THRESH="$OPTARG" ;;
t) AUDIO_LOW_THRESH="$OPTARG" ;;
C) DEFAULT_COLOR="$OPTARG" ;;
c) MUTED_COLOR="$OPTARG" ;;
i) AUDIO_INTERVAL="$OPTARG" ;;
m) MIXER="$OPTARG" ;;
s) SCONTROL="$OPTARG" ;;
h) printf \
"Usage: volume-pulseaudio [-S] [-F format] [-f format] [-p] [-a|-d] [-H symb] [-M symb]
[-L symb] [-X symb] [-T thresh] [-t thresh] [-C color] [-c color] [-i inter]
[-m mixer] [-s scontrol] [-h]
Options:
-F, -f\tOutput format (-F long format, -f short format) to use, amongst:
\t0\t symb vol [index:name]\t (default long)
\t1\t symb vol [name]
\t2\t symb vol [index]\t (default short)
\t3\t symb vol
-S\tSubscribe to volume events (requires persistent block, always uses long format)
-p\tOmit the percent sign (%%) in volume
-a\tUse ALSA name if possible
-d\tUse device description instead of name if possible
-H\tSymbol to use when audio level is high. Default: '$AUDIO_HIGH_SYMBOL'
-M\tSymbol to use when audio level is medium. Default: '$AUDIO_MED_SYMBOL'
-L\tSymbol to use when audio level is low. Default: '$AUDIO_LOW_SYMBOL'
-X\tSymbol to use when audio is muted. Default: '$AUDIO_MUTED_SYMBOL'
-T\tThreshold for medium audio level. Default: $AUDIO_MED_THRESH
-t\tThreshold for low audio level. Default: $AUDIO_LOW_THRESH
-C\tColor for non-muted audio. Default: $DEFAULT_COLOR
-c\tColor for muted audio. Default: $MUTED_COLOR
-i\tInterval size of volume increase/decrease. Default: $AUDIO_INTERVAL
-m\tUse the given mixer.
-s\tUse the given scontrol.
-h\tShow this help text
" && exit 0;;
esac
done
capability() { # Return "Capture" if the device is a capture device
amixer -D $MIXER get $SCONTROL |
sed -n "s/ Capabilities:.*cvolume.*/Capture/p"
}
volume() {
amixer -D $MIXER get $SCONTROL $(capability)
}
format() {
perl_filter='if (/.*\[(\d+)%\] (\[(-?\d+.\d+)dB\] )?\[(on|off)\]/)'
perl_filter+='{CORE::say $4 eq "off" ? "-1" : "'
perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1')
perl_filter+='"; exit}'
perl -ne "$perl_filter"
}
#------------------------------------------------------------------------
case $BLOCK_BUTTON in
1) pavucontrol &>/dev/null &;;
2) ~/.config/i3/cycleaudio.py;;
3) amixer -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute
4) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase
5) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease
esac
#------------------------------------------------------------------------
VOL=$(volume | format)
ACTIVE=$(pacmd list-sinks | grep '* index' | awk -F": " '{print $2}')
if pactl list short sinks | grep -q \^$ACTIVE".*Yeti"; then
printf ""
elif pactl list short sinks | grep -q \^$ACTIVE".*bluez"; then
printf " "
elif [ "$VOL" -eq -1 ]; then
printf "X"
exit 0
elif [ "$VOL" -eq 0 ]; then
printf ""
elif [ "$VOL" -gt 59 ]; then
printf ""
else
printf ""
if [[ -z "$MIXER" ]] ; then
MIXER="default"
if amixer -D pulse info >/dev/null 2>&1 ; then
MIXER="pulse"
fi
fi
printf " $VOL"
if [[ -z "$SCONTROL" ]] ; then
SCONTROL=$(amixer -D "$MIXER" scontrols | sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | head -n1)
fi
CAPABILITY=$(amixer -D $MIXER get $SCONTROL | sed -n "s/ Capabilities:.*cvolume.*/Capture/p")
function move_sinks_to_new_default {
DEFAULT_SINK=$1
pacmd list-sink-inputs | grep index: | grep -o '[0-9]\+' | while read SINK
do
pacmd move-sink-input $SINK $DEFAULT_SINK
done
}
function set_default_playback_device_next {
inc=${1:-1}
num_devices=$(pacmd list-sinks | grep -c index:)
sink_arr=($(pacmd list-sinks | grep index: | grep -o '[0-9]\+'))
default_sink_index=$(( $(pacmd list-sinks | grep index: | grep -no '*' | grep -o '^[0-9]\+') - 1 ))
default_sink_index=$(( ($default_sink_index + $num_devices + $inc) % $num_devices ))
default_sink=${sink_arr[$default_sink_index]}
pacmd set-default-sink $default_sink
move_sinks_to_new_default $default_sink
}
case "$BLOCK_BUTTON" in
1) set_default_playback_device_next ;;
2) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY toggle ;;
3) set_default_playback_device_next -1 ;;
4) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_INTERVAL%+ ;;
5) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_INTERVAL%- ;;
esac
function print_format {
PERCENT="%"
[[ $USE_PERCENT == 0 ]] && PERCENT=""
case "$1" in
1) echo "$SYMBOL$VOL$PERCENT [$NAME]" ;;
2) echo "$SYMBOL$VOL$PERCENT [$INDEX]";;
3) echo "$SYMBOL$VOL$PERCENT" ;;
*) echo "$SYMBOL$VOL$PERCENT [$INDEX:$NAME]" ;;
esac
}
function print_block {
for name in INDEX NAME VOL MUTED; do
read $name
done < <(pacmd list-sinks | grep "index:\|name:\|volume: front\|muted:" | grep -A3 '*')
INDEX=$(echo "$INDEX" | grep -o '[0-9]\+')
VOL=$(echo "$VOL" | grep -o "[0-9]*%" | head -1 )
VOL="${VOL%?}"
NAME=$(echo "$NAME" | sed \
's/.*<.*\.\(.*\)>.*/\1/; t;'\
's/.*<\(.*\)>.*/\1/; t;'\
's/.*/unknown/')
if [[ $USE_ALSA_NAME == 1 ]] ; then
ALSA_NAME=$(pacmd list-sinks |\
awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\
grep "alsa.name\|alsa.mixer_name" |\
head -n1 |\
sed 's/.*= "\(.*\)".*/\1/')
NAME=${ALSA_NAME:-$NAME}
elif [[ $USE_DESCRIPTION == 1 ]] ; then
DESCRIPTION=$(pacmd list-sinks |\
awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\
grep "device.description" |\
head -n1 |\
sed 's/.*= "\(.*\)".*/\1/')
NAME=${DESCRIPTION:-$NAME}
fi
if [[ $MUTED =~ "no" ]] ; then
SYMBOL=$AUDIO_HIGH_SYMBOL
[[ $VOL -le $AUDIO_MED_THRESH ]] && SYMBOL=$AUDIO_MED_SYMBOL
[[ $VOL -le $AUDIO_LOW_THRESH ]] && SYMBOL=$AUDIO_LOW_SYMBOL
COLOR=$DEFAULT_COLOR
else
SYMBOL=$AUDIO_MUTED_SYMBOL
COLOR=$MUTED_COLOR
VOL=""
fi
# if [[ $SUBSCRIBE == 1 ]] ; then
# print_format "$LONG_FORMAT"
# else
# print_format "$LONG_FORMAT"
print_format "$SHORT_FORMAT"
# echo "$COLOR"
# fi
}
print_block
if [[ $SUBSCRIBE == 1 ]] ; then
while read -r EVENT; do
print_block
done < <(pactl subscribe | stdbuf -oL grep change)
fi

View File

@ -151,7 +151,7 @@ bindsym $mod+space exec "pkill rofi; rofi -show run -sidebar-mode -terminal i3
bindsym --release Print exec imgur-screenshot
bindsym --release $mod+Print exec imgur-screenshot -f
bindsym $mod+Mod1+space exec --no-startup-id ~/.config/i3/cycleaudio.py && pkill -RTMIN+10 i3blocks
bindsym $mod+numbersign exec notify-send "$(xclip -o | gpg --decrypt 2>&1)"
bindsym $mod+numbersign exec "termite -e 'sh -c xclip\ -o\ |\ gpg\ --decrypt\ 2>&1\ &&\ read'"
bindsym $mod+g exec "LINK=$(gist -PRpc); notify-send -c transfer \\"<a href=\\\\"$LINK\\\\">$LINK</a>\\""
# Media player controls
@ -160,12 +160,12 @@ bindsym XF86AudioPause exec --no-startup-id mpc pause
bindsym XF86AudioStop exec --no-startup-id mpc stop
bindsym XF86AudioNext exec --no-startup-id mpc next
bindsym XF86AudioPrev exec --no-startup-id mpc previous
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +1000
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -1000
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle
bindsym XF86MonBrightnessUp exec xbacklight -inc 5 && pkill -RTMIN+12 i3blocks
bindsym XF86MonBrightnessDown exec xbacklight -dec 5 && pkill -RTMIN+12 i3blocks
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +2% && pkill -RTMIN+10 i3blocks
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -2% && pkill -RTMIN+10 i3blocks
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && pkill -RTMIN+10 i3blocks
exec --no-startup-id "ip monitor | while read line; do pkill -RTMIN+15 i3blocks; done"
exec --no-startup-id "ip monitor | while read; do pkill -RTMIN+15 i3blocks; done"
# app launch shortcuts
exec --no-startup-id ~/.fehbg

View File

@ -5,9 +5,6 @@ tmpbg='/tmp/screen.png'
(( $# )) && { icon=$1; }
# screenshot
scrot "$tmpbg"
PX=0
PY=0
# lockscreen image info
@ -25,17 +22,19 @@ SROY=$(echo $RES | cut -d'x' -f 2 | cut -d'+' -f 3) # y offset
PX=$(($SROX + $SRX/2 - $RX/2))
PY=$(($SROY + $SRY/2 - $RY/2))
# screenshot, pixelise and overlay
maim | convert - -scale 5% -scale 2000% $icon -geometry +$PX+$PY -composite -matte $tmpbg
# pixelize and add lock icon
convert $tmpbg -scale 5% -scale 2000% $tmpbg
convert $tmpbg $icon -geometry +$PX+$PY -composite -matte $tmpbg
playing=$(mpc status | grep playing | wc -l)
[[ $playing == 1 ]] && mpc pause
if command mpc 2>&1 1>/dev/null; then
playing=$(mpc status | grep playing | wc -l)
[[ $playing == 1 ]] && mpc pause
fi
i3lock -i "$tmpbg" -n -e
[[ $playing == 1 ]] && mpc play
if command mpc 2>&1 1>/dev/null; then
[[ $playing == 1 ]] && mpc play
fi
rm "$tmpbg"

View File

@ -4,10 +4,10 @@ imgur_secret=""
login="false"
log_file="$HOME/.config/imgur-screenshot/imgur-screenshot.log"
credentials_file="$HOME/.config/imgur-screenshot/credentials.conf"
file_name_format="scrot-%Y-%m-%d--%H:%M:%S.png" # when using scrot, must end with .png!
file_name_format="screenshot-%Y-%m-%d-%H%M%S.png" # when using scrot, must end with .png!
file_dir="$HOME/pictures/screenshots"
screenshot_select_command="scrot -q 0 -s %img"
screenshot_window_command="scrot -q 0 -b %img"
screenshot_select_command="maim -m 10 -us %img"
screenshot_window_command="maim -m 10 -uw %img"
edit_command="gimp %img"
edit="false"
exit_on_selection_fail="true"

View File

@ -1,15 +1,15 @@
# thumb wheel up => increase volume and unmute
"amixer -D pulse set Master 1000+ unmute ; pkill -RTMIN+10 i3blocks"
b:6
# thumb wheel down => lower volume
"amixer -D pulse set Master 1000- ; pkill -RTMIN+10 i3blocks"
b:7
# backward button => previous song
"xte 'key XF86AudioPrev'"
b:8
# forward button => next song
"xte 'key XF86AudioNext'"
# thumb wheel up => increase volume and unmute
"xdotool key --clearmodifiers XF86AudioRaiseVolume"
b:6
# thumb wheel down => lower volume
"xdotool key --clearmodifiers XF86AudioLowerVolume"
b:7
# backward button => previous song
"xte 'key XF86AudioPrev'"
b:8
# forward button => next song
"xte 'key XF86AudioNext'"
b:9

15
aliases
View File

@ -11,16 +11,15 @@ alias ..ll="cd..;ll"
alias ..l="..ll"
alias l=ll
alias ll="ls -lFh"
alias la="ls -lAFh"
alias lat='la -t'
alias ll="ls -lFh --group-directories-first"
alias la="ls -lAFh --group-directories-first"
alias lt='ls -lAFh --sort=time'
alias al=la # No, I don't need the Mono Assembly Linker
alias md="mkdir -p"
alias rd="rmdir -p"
mcd(){
mkdir -p $1 && cd $1
}
mcd(){ mkdir -p $@ && cd $@; }
alias -- -='cd -'
alias cdt='cd `mktemp -d`'
alias grep='grep --color'
alias -g H='| head'
@ -53,6 +52,7 @@ alias cp='cp -ir'
alias pacman='pacman --color=always'
alias pacaur='pacaur --color=always'
alias tree='tree --dirsfirst -C -F'
alias make="make -j$(nproc)"
alias dd='dd status=progress'
alias env='env | sort'
alias ssh="ssh -tt"
@ -132,6 +132,7 @@ gd() {
fi
}
alias gds="git diff --staged --color-words"
alias gsh="git show --color-words"
alias glg="git log --stat --color"
alias glog="git log --oneline --decorate --color --graph"
@ -148,7 +149,7 @@ alias grro="grr origin"
alias gsta='git stash'
alias gstd='gsta drop'
alias gstl='gsta list'
alias gstl='gsta list --stat --color'
alias gstp='gsta pop'
alias gstv="gsta show -p stash@{0}"