~andrewzah/dotfiles

a000b10a515a3d3b5b394d1cc71fe4c1b7267615 — Andrew Zah 6 years ago 701233b
remove .i3 folder, remove i3blocks in favor of polybar
5 files changed, 0 insertions(+), 483 deletions(-)

D .config/i3/blocks/mpd.sh
D .config/i3/blocks/volume-pulseaudio
D .i3/blocks/mpd.sh
D .i3/blocks/volume-pulseaudio
D .i3/config
D .config/i3/blocks/mpd.sh => .config/i3/blocks/mpd.sh +0 -12
@@ 1,12 0,0 @@
#!/bin/bash 
NCMP=$(mpc -h ~/.config/mpd/socket | grep "^\[playing\]" | awk '{print $1}')
NUM_NCMP=$(mpc -h ~/.config/mpd/socket | head -1 | wc -c )
S_NCMP=$(mpc -h ~/.config/mpd/socket | head -1 | head -c 100)

if [ "$NCMP" = "[playing]" ]; then 
    if [ "$NUM_NCMP" -lt 100 ]; then 
        echo -e ": $(mpc -h ~/.config/mpd/socket current)"
    else
        echo -e ": $S_NCMP..."
    fi
fi

D .config/i3/blocks/volume-pulseaudio => .config/i3/blocks/volume-pulseaudio +0 -181
@@ 1,181 0,0 @@
#!/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=""
    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
    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

D .i3/blocks/mpd.sh => .i3/blocks/mpd.sh +0 -12
@@ 1,12 0,0 @@
#!/bin/bash 
NCMP=$(mpc -h ~/.config/mpd/socket | grep "^\[playing\]" | awk '{print $1}')
NUM_NCMP=$(mpc -h ~/.config/mpd/socket | head -1 | wc -c )
S_NCMP=$(mpc -h ~/.config/mpd/socket | head -1 | head -c 100)

if [ "$NCMP" = "[playing]" ]; then 
    if [ "$NUM_NCMP" -lt 100 ]; then 
        echo -e ": $(mpc -h ~/.config/mpd/socket current)"
    else
        echo -e ": $S_NCMP..."
    fi
fi

D .i3/blocks/volume-pulseaudio => .i3/blocks/volume-pulseaudio +0 -181
@@ 1,181 0,0 @@
#!/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=""
    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
    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

D .i3/config => .i3/config +0 -97
@@ 1,97 0,0 @@
## font
font pango:DejaVu Sans Mono 10

## i3 ModKeys
set $mod Mod4
set $cmod Mod1

gaps inner 10
set $work1 "Neptune"
set $work2 "Saturn"
set $work3 "Titan"
set $work4 "Venus"
set $work5 "Jupiter"
set $work6 "Mars"

# default workspaces to each monitor
workspace $work1 output DVI-I-1
workspace $work2 output HDMI-0

# startup applications
exec_always --no-startup-id ~/.config/i3/polybar.sh &
exec_always feh --bg-scale ~/Pictures/Wallpapers/deoksugung2_right.jpg ~/Pictures/Wallpapers/deoksugung2_left.jpg

## i3 Opts
hide_edge_borders both
new_window pixel 2

# Floating mode
#floating_modifer $mod

# Focus keys
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# Move keys
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

# Move workspaces
bindsym $mod+1 workspace $work1
bindsym $mod+2 workspace $work2
bindsym $mod+3 workspace $work3
bindsym $mod+4 workspace $work4
bindsym $mod+5 workspace $work5
bindsym $mod+6 workspace $work6

# resize windows
bindsym $mod+Ctrl+Shift+Right resize shrink width 10 px or 10 ppt
bindsym $mod+Ctrl+Shift+Up resize grow height 10 px or 10 ppt
bindsym $mod+Ctrl+Shift+Down resize shrink height 10 px or 10 ppt
bindsym $mod+Ctrl+Shift+Left resize grow width 10 px or 10 ppt

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $work1
bindsym $mod+Shift+2 move container to workspace $work2
bindsym $mod+Shift+3 move container to workspace $work3
bindsym $mod+Shift+4 move container to workspace $work4
bindsym $mod+Shift+5 move container to workspace $work5
bindsym $mod+Shift+6 move container to workspace $work6

# assign programs to workspaces
assign [class="Discord"] $work2
assign [class="Thunderbird"] $work3

# splits
bindsym $mod+h split h
bindsym $mod+v split v

# toggling view types
bindsym $mod+s layout stacking
bindsym $mod+l layout toggle split
bindsym $mod+f fullscreen toggle
bindsym $mod+g floating toggle


## i3 Session keys
bindsym $mod+Shift+c reload
bindsym $mod+Shift+r restart
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3?' -b 'Yes, exit i3' 'i3-msg exit'"

# General
bindsym $mod+Return exec kitty
bindsym $mod+d exec rofi -show run -config /home/andrei/.config/rofi/config
bindsym $mod+w exec rofi -show window -config /home/andrei/.config/rofi/config
bindsym $mod+Shift+w kill

# Floating windows
for_window [class="Peek"] floating enable

client.focused          #5F875F #285577 #ffffff #97b597   #5F875F
client.focused_inactive #333333 #5f676a #ffffff #484e50   #5f676a
client.unfocused        #333333 #222222 #888888 #292d2e   #222222
client.urgent           #2f343a #900000 #ffffff #900000   #900000