Fix i3 scripts

This commit is contained in:
drymer 2018-05-06 20:39:11 +02:00
parent 3862042a06
commit 8a6f234e5c
5 changed files with 223 additions and 12 deletions

View File

@ -3,7 +3,6 @@
set $color_bad = #CC0000
set $color_degraded = #EDD400
set $color_good = #73D216
set $mod Mod4
# Fuente para títulos de ventanas
@ -13,7 +12,8 @@ font pango:DejaVu Sans Mono 8
floating_modifier $mod
# Display
set $display eDP-1
set $display1 eDP-1
set $display2 DP-1
# volver a la misma ventana que estaba apretando el mismo worskpace
workspace_auto_back_and_forth yes
@ -79,12 +79,12 @@ set $ws1 1<big></big>
set $ws2 2<big></big>
set $ws3 3<big></big>
set $ws4 4<big></big>
set $ws5 5<big></big>
set $ws6 6<big></big>
set $ws7 7<big></big>
set $ws8 8<big></big>
set $ws5 5<big></big>
set $ws6 6<big></big>
set $ws7 7<big></big>
set $ws8 8<big></big>
set $ws9 9<big></big>
set $ws10 10
set $ws10 10<big></big>
# Cambiar a workspace
bindsym $mod+1 workspace $ws1
@ -111,8 +111,16 @@ bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10
# Workspace a monitores
workspace $ws1 output $display2
workspace $ws2 output $display2
workspace $ws3 output $display1
workspace $ws4 output $display2
workspace $ws5 output $display2
workspace $ws6 output $display2
workspace $ws7 output $display1
workspace $ws8 output $display1
workspace $ws9 output $display1
workspace $ws10 output $display1
# Cambiar tamaño de ventana
mode "Resize" {
@ -181,12 +189,14 @@ client.urgent #FF0000 #8C5665 #ffffff #FF0000
exec --no-startup-id feh --bg-scale ~/Imagenes/debian-background.jpg
# Autostart
exec --no-startup-id xbacklight -set 50
exec --no-startup-id bash ~/.xinitrc
exec --no-startup-id bash ~/.i3/scripts/autolock.sh
exec --no-startup-id parcellite
exec --no-startup-id compton
exec --no-startup-id dunst
exec --no-startup-id xcape
exec --no-startup-id /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd
# Mover programas automáticamente a workspace
assign [class="(?i)firefox"] $ws2
@ -214,7 +224,8 @@ for_window [class="(?i)feh"] floating enable
for_window [class="Progreso de operación de archivo"] floating enable
for_window [title="textarea"] floating enable
for_window [title="qutebrowser-editor"] floating enable
for_window [title="SM-J710F"] floating enable
for_window [title="Dispositivos Bluetooth"] floating enable
# i3-gaps
smart_borders on
@ -229,3 +240,9 @@ bindsym $mod+Shift+p move scratchpad
bindsym $mod+p scratchpad show
exec keepassx
for_window [title="KeePassX"] border 1pixel, floating enable, move scratchpad
# keybinds varios
bindsym XF86MonBrightnessUp exec --no-startup-id luz 1
bindsym XF86MonBrightnessDown exec --no-startup-id luz 2
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 7 +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 7 -5% #decrease sound volume

View File

@ -55,14 +55,22 @@ border_top=0
border_right=0
border_left=-1
[volume]
instance=Master
[volume-pulseaudio]
# command=/home/ap/.i3/scripts/volume-pulseaudio -a | head -n1 | awk -F '[' '{print $1}'
interval=once
signal=1
border_top=0
border_right=0
border_left=-1
# [volume]
# instance=Master
# interval=once
# signal=1
# border_top=0
# border_right=0
# border_left=-1
[date]
interval=1
border_top=0

View File

@ -23,7 +23,7 @@
# 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"
MIXER="pulse"
[ -n "$(lsmod | grep pulse)" ] && MIXER="pulse"
[ -n "$(lsmod | grep jack)" ] && MIXER="jackplug"
MIXER="${2:-$MIXER}"

View File

@ -0,0 +1,177 @@
#!/bin/bash
# Displays the default device, volume, and mute status for i3blocks
AUDIO_HIGH_SYMBOL=' '
AUDIO_MED_THRESH=50
AUDIO_MED_SYMBOL=' '
AUDIO_LOW_THRESH=0
AUDIO_LOW_SYMBOL=' '
AUDIO_MUTED_SYMBOL=' '
AUDIO_INTERVAL=5
DEFAULT_COLOR="#ffffff"
MUTED_COLOR="#a0a0a0"
LONG_FORMAT=0
SHORT_FORMAT=2
USE_PERCENT=1
USE_ALSA_NAME=0
USE_DESCRIPTION=0
SUBSCRIBE=0
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
if [[ -z "$MIXER" ]] ; then
MIXER="default"
if amixer -D pulse info >/dev/null 2>&1 ; then
MIXER="pulse"
fi
fi
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=""
echo -n '<span background="#4c83ff" foreground="#8A458A"></span><span background="#8A458A" foreground="black"> </span>'
echo -e "<span background=\"#8A458A\" foreground=\"black\">$VOL$PERCENT</span><span foreground=\"#ffd700\" background=\"#8A458A\"> </span>"
}
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
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

@ -21,11 +21,20 @@ OUTPUT=$(curl --silent http://api.openweathermap.org/data/2.5/weather\?APPID\=$A
TEMP=$(echo $OUTPUT | jq -r ".main.temp")
WEATHER=$(echo $OUTPUT | jq -r ".weather[0].main")
case $WEATHER in
"Clear"*)
"Snow"*)
WEATHER=
echo "<span foreground='#FF1535' background='black'></span><span foreground='black' background='#FF1535'> $WEATHER $TEMP°C</span><span foreground='#61CE3C' background='#FF1535'> </span>"
;;
"Clear"*)
WEATHER=
echo "<span foreground='#ffd700' background='black'></span><span foreground='black' background='#ffd700'> $WEATHER $TEMP°C</span><span foreground='#61CE3C' background='#ffd700'> </span>"
;;
"Drizzle"*)
WEATHER=
echo "<span foreground='#FF1535' background='black'></span><span foreground='black' background='#FF1535'> $WEATHER $TEMP°C</span><span foreground='#61CE3C' background='#FF1535'> </span>"
;;
"Rain"*)
WEATHER=
echo "<span foreground='#FF1535' background='black'></span><span foreground='black' background='#FF1535'> $WEATHER $TEMP°C</span><span foreground='#61CE3C' background='#FF1535'> </span>"