commit 9530a997f33cae179060a2b6e1ebcdf0d0a0bcad parent 99a030ec721eadfd234121122f4bc487d189b8d3 Author: Oscar Benedito <oscar@oscarbenedito.com> Date: Sun, 21 Jun 2020 19:42:38 +0200 Changed i3, i3blocks and i3lock for dwm, dwmblocks and slock Diffstat:
M | .config/files | | | 2 | -- |
D | .config/i3/config | | | 286 | ------------------------------------------------------------------------------- |
D | .config/i3blocks/bin/apt-updates | | | 5 | ----- |
D | .config/i3blocks/bin/backlight | | | 41 | ----------------------------------------- |
D | .config/i3blocks/bin/battery2 | | | 93 | ------------------------------------------------------------------------------- |
D | .config/i3blocks/bin/disk | | | 4 | ---- |
D | .config/i3blocks/bin/volume-pulseaudio | | | 182 | ------------------------------------------------------------------------------- |
D | .config/i3blocks/config | | | 28 | ---------------------------- |
M | .config/zsh/.zshenv | | | 3 | ++- |
A | .local/bin/dwmblocks/dwmb-apt-updates | | | 5 | +++++ |
A | .local/bin/dwmblocks/dwmb-backlight | | | 2 | ++ |
A | .local/bin/dwmblocks/dwmb-battery2 | | | 80 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | .local/bin/dwmblocks/dwmb-date | | | 3 | +++ |
A | .local/bin/dwmblocks/dwmb-disk | | | 4 | ++++ |
A | .local/bin/dwmblocks/dwmb-volume | | | 182 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
D | .local/bin/i3-lock | | | 16 | ---------------- |
A | .local/share/dwm/autostart.sh | | | 24 | ++++++++++++++++++++++++ |
17 files changed, 302 insertions(+), 658 deletions(-)
diff --git a/.config/files b/.config/files @@ -1,11 +1,9 @@ # shortcuts for files cfa $XDG_CONFIG_HOME/zsh/aliases cfal $XDG_CONFIG_HOME/alacritty/alacritty.yml -cfb $XDG_CONFIG_HOME/i3blocks/config cfd $XDG_CONFIG_HOME/directories cfe $XDG_CONFIG_HOME/zsh/.zshenv cff $XDG_CONFIG_HOME/files -cfi $XDG_CONFIG_HOME/i3/config cfv $XDG_CONFIG_HOME/nvim/init.vim cfx $HOME/.Xresources cfz $XDG_CONFIG_HOME/zsh/.zshrc diff --git a/.config/i3/config b/.config/i3/config @@ -1,286 +0,0 @@ -# _ _____ __ __ _ -# (_)___ / / /__ ___ _ __ / _(_) __ _ -# | | |_ \ / / __/ _ \| '_ \| |_| |/ _` | -# | |___) / / (_| (_) | | | | _| | (_| | -# |_|____/_/ \___\___/|_| |_|_| |_|\__, | -# |___/ - -# initial declarations {{{ - -set $mod Mod4 -font pango:monospace 10 - -# /initial declarations }}} - -# shortcuts {{{ - -# reload the configuration file -bindsym $mod+Shift+c reload - -# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) -bindsym $mod+Shift+r restart - -# start a terminal -bindsym $mod+Return exec alacritty -bindsym $mod+KP_Enter exec alacritty - -# start i3-dmenu-desktop (dmenu wrapper with support for .desktop files) -bindsym $mod+d exec --no-startup-id j4-dmenu-desktop - -# open program shortcuts -set $ai $HOME/.local/share/applications -bindsym $mod+o mode "$mode_open" -set $mode_open (f)irefox, (k)eepassxc, (n)extcloud, (s)ignal, (t)utanota -mode "$mode_open" { - bindsym f exec firefox, mode "default" - bindsym k exec "$HOME/.local/bin/appimage $ai/keepassxc.desktop", mode "default" - bindsym n exec "$HOME/.local/bin/appimage $ai/nextcloud.desktop", mode "default" - bindsym s exec "signal-desktop --no-sandbox", mode "default" - bindsym t exec "$HOME/.local/bin/appimage $ai/tutanota-desktop.desktop", mode "default" - - # exit open mode: "Enter" or "Escape" - bindsym Return mode "default" - bindsym Escape mode "default" -} - -# mount/unmount drives -bindsym $mod+m exec "$HOME/.local/bin/mount-drive" - -# take screenshot -bindsym Print --release exec "scrot --select /tmp/screenshot-$(date +%F_%T).png --exec 'xclip -selection c -target image/png < $f'; notify-send 'Screenshot copied to clipboard'" -bindsym Shift+Print exec "scrot /tmp/screenshot-$(date +%F_%T).png --exec 'xclip -selection c -target image/png < $f'; notify-send 'Screenshot copied to clipboard'" - -# /shortcuts }}} - -# windows {{{ - -# kill focused window -bindsym $mod+Shift+q kill - -# Use Mouse+$mod to drag floating windows to their wanted position -floating_modifier $mod - -# change focus -bindsym $mod+h focus left -bindsym $mod+j focus down -bindsym $mod+k focus up -bindsym $mod+l focus right - -# alternatively, you can use the cursor keys: -bindsym $mod+Left focus left -bindsym $mod+Down focus down -bindsym $mod+Up focus up -bindsym $mod+Right focus right - -# move focused window -bindsym $mod+Shift+h move left -bindsym $mod+Shift+j move down -bindsym $mod+Shift+k move up -bindsym $mod+Shift+l move right - -# alternatively, you can use the cursor 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 - -# toggle split orientation (horizontal/vertical) -bindsym $mod+v split toggle;exec notify-send 'tile toggled' - -# enter fullscreen mode for the focused container -bindsym $mod+f fullscreen toggle - -# change container layout (stacked, tabbed, toggle split) -bindsym $mod+s layout stacking -bindsym $mod+t layout tabbed -bindsym $mod+e layout toggle split - -# toggle tiling / floating -bindsym $mod+Shift+space floating toggle - -# change focus between tiling / floating windows -bindsym $mod+Control+space focus mode_toggle - -# focus the parent container -bindsym $mod+a focus parent - -# focus the child container -#bindsym $mod+d focus child - -mode "resize" { - # These bindings trigger as soon as you enter the resize mode - - # Pressing left will shrink the window’s width. - # Pressing right will grow the window’s width. - # Pressing up will shrink the window’s height. - # Pressing down will grow the window’s height. - bindsym h resize shrink width 5 px or 5 ppt - bindsym j resize grow height 5 px or 5 ppt - bindsym k resize shrink height 5 px or 5 ppt - bindsym l resize grow width 5 px or 5 ppt - - # same bindings, but for the arrow keys - bindsym Left resize shrink width 10 px or 10 ppt - bindsym Down resize grow height 10 px or 10 ppt - bindsym Up resize shrink height 10 px or 10 ppt - bindsym Right resize grow width 10 px or 10 ppt - - # back to normal: Enter or Escape or $mod+r - bindsym Return mode "default" - bindsym Escape mode "default" - bindsym $mod+r mode "default" -} - -bindsym $mod+r mode "resize" - -# /windows }}} - -# workspaces {{{ - -# We use variables to avoid repeating the names in multiple places. -set $ws1 "1" -set $ws2 "2" -set $ws3 "3" -set $ws4 "4" -set $ws5 "5" -set $ws6 "6" -set $ws7 "7" -set $ws8 "8" -set $ws9 "9" -set $ws10 "10" - -# switch to workspace -bindsym $mod+1 workspace $ws1 -bindsym $mod+2 workspace $ws2 -bindsym $mod+3 workspace $ws3 -bindsym $mod+4 workspace $ws4 -bindsym $mod+5 workspace $ws5 -bindsym $mod+6 workspace $ws6 -bindsym $mod+7 workspace $ws7 -bindsym $mod+8 workspace $ws8 -bindsym $mod+9 workspace $ws9 -bindsym $mod+0 workspace $ws10 - -# move focused container to workspace and switch to workspace -bindsym $mod+Shift+1 move container to workspace $ws1; workspace $ws1 -bindsym $mod+Shift+2 move container to workspace $ws2; workspace $ws2 -bindsym $mod+Shift+3 move container to workspace $ws3; workspace $ws3 -bindsym $mod+Shift+4 move container to workspace $ws4; workspace $ws4 -bindsym $mod+Shift+5 move container to workspace $ws5; workspace $ws5 -bindsym $mod+Shift+6 move container to workspace $ws6; workspace $ws6 -bindsym $mod+Shift+7 move container to workspace $ws7; workspace $ws7 -bindsym $mod+Shift+8 move container to workspace $ws8; workspace $ws8 -bindsym $mod+Shift+9 move container to workspace $ws9; workspace $ws9 -bindsym $mod+Shift+0 move container to workspace $ws10; workspace $ws10 - -# move focused container to workspace without switching workspaces -bindsym $mod+Control+1 move container to workspace $ws1 -bindsym $mod+Control+2 move container to workspace $ws2 -bindsym $mod+Control+3 move container to workspace $ws3 -bindsym $mod+Control+4 move container to workspace $ws4 -bindsym $mod+Control+5 move container to workspace $ws5 -bindsym $mod+Control+6 move container to workspace $ws6 -bindsym $mod+Control+7 move container to workspace $ws7 -bindsym $mod+Control+8 move container to workspace $ws8 -bindsym $mod+Control+9 move container to workspace $ws9 -bindsym $mod+Control+0 move container to workspace $ws10 - -# /workspaces }}} - -# session commands {{{ - -# exit session -bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'" - -bindsym $mod+i mode "$mode_system" -set $mode_system (l)ock, (e)xit, (r)eboot, (s)hutdown -mode "$mode_system" { - bindsym l exec --no-startup-id "$HOME/.local/bin/i3-lock", mode "default" - bindsym e exec --no-startup-id "i3-msg exit", mode "default" - bindsym r exec --no-startup-id "systemctl reboot", mode "default" - bindsym s exec --no-startup-id "systemctl poweroff", mode "default" - - # exit system mode: "Enter" or "Escape" - bindsym Return mode "default" - bindsym Escape mode "default" -} - -# Autolock after 5 minutes of inactivity -exec --no-startup-id xautolock -detectsleep -corners 0-00 -time 5 -locker "$HOME/.local/bin/i3-lock" -notify 30 -notifier "notify-send -u critical -t 10000 'Locking screen in 30 seconds'" - -# /session commands }}} - -# theme {{{ - -# borders and gaps -for_window [class="^.*"] border pixel 2 -gaps inner 10 -smart_gaps on -smart_borders on - -# status bar -bar { - font pango:mono 10 - status_command i3blocks - position top - tray_output none - - colors { - background #000000 - statusline #eeeeee - separator #666666 - # border backgr. text - focused_workspace #4c7899 #285577 #eeeeee - active_workspace #9da1a8 #797e89 #eeeeee - inactive_workspace #333333 #222222 #888888 - urgent_workspace #6fa24c #51852c #eeeeee - } -} - -# wallpaper -set $wp $HOME/.config/i3/wallpaper.png -exec --no-startup-id "xwallpaper --zoom $wp" - -# /theme }}} - -# volume and brightness {{{ - -# volume -bindsym XF86AudioRaiseVolume exec amixer -q -D pulse sset Master unmute && amixer -q -D pulse sset Master 5%+ && pkill -RTMIN+1 i3blocks -bindsym XF86AudioLowerVolume exec amixer -q -D pulse sset Master unmute && amixer -q -D pulse sset Master 5%- && pkill -RTMIN+1 i3blocks -bindsym XF86AudioMute exec amixer -q -D pulse sset Master toggle && pkill -RTMIN+1 i3blocks - -bindsym $mod+plus exec amixer -q -D pulse sset Master unmute && amixer -q -D pulse sset Master 5%+ && pkill -RTMIN+1 i3blocks -bindsym $mod+minus exec amixer -q -D pulse sset Master unmute && amixer -q -D pulse sset Master 5%- && pkill -RTMIN+1 i3blocks - -# brightness -bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -dec 10 && pkill -RTMIN+2 i3blocks -bindsym XF86MonBrightnessUp exec --no-startup-id xbacklight -inc 10 && pkill -RTMIN+2 i3blocks - -# /volume and brightness }}} - -# keyboards and monitors {{{ - -# use caps as super -exec --no-startup-id "setxkbmap -option 'caps:super'" - -# tap caps for escape (hold down for super) -exec --no-startup-id "xcape -e 'Super_L=Escape'" - -# activate num lock -exec --no-startup-id "numlockx" - -# configure monitors -exec --no-startup-id "$HOME/.local/bin/configure-monitors" - -# toggle keymap -bindsym $mod+space exec "$HOME/.local/bin/toggle-kbmap" - -# /keyboards and monitors }}} - -# other {{{ - -# connect to vpn -exec --no-startup-id "mullvad connect" - -# other }}} diff --git a/.config/i3blocks/bin/apt-updates b/.config/i3blocks/bin/apt-updates @@ -1,5 +0,0 @@ -#!/usr/bin/env sh - -sudo apt-get update > /dev/null 2> /dev/null -UPDATES="$(apt-get upgrade -s |grep -P '^\d+ upgraded'|cut -d" " -f1)" -[ "0" != "$UPDATES" ] && echo "<span font='FontAwesome'></span> $UPDATES" diff --git a/.config/i3blocks/bin/backlight b/.config/i3blocks/bin/backlight @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -# Show the screen brightness value given by `xbacklight`. -# Clicking uses `xset` to turn off the backlight, scrolling increases or decreases -# the brightness. - -# Copyright 2019 Johannes Lange -# -# 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. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -STEP_SIZE=${STEP_SIZE:-10} -USE_SUDO=${USE_SUDO:-0} - -# whether to use `sudo` for changing the brightness (requires a NOPASSWD rule) -if [[ "$USE_SUDO" == "0" ]] ; then - XBACKLIGHT_SET="xbacklight" -else - XBACKLIGHT_SET="sudo xbacklight" -fi - -case $BLOCK_BUTTON in - 3) xset dpms force off ;; # right click - 4) $XBACKLIGHT_SET -inc "$STEP_SIZE" ;; # scroll up - 5) $XBACKLIGHT_SET -dec "$STEP_SIZE" ;; # scroll down, decrease -esac - - -BRIGHTNESS=$(xbacklight -get) -echo "<span font='FontAwesome'>☀</span> ${BRIGHTNESS}%" | sed "s/\.[0-9]*//g" diff --git a/.config/i3blocks/bin/battery2 b/.config/i3blocks/bin/battery2 @@ -1,93 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 James Murphy -# Licensed under the GPL version 2 only -# -# A battery indicator blocklet script for i3blocks - -import re -from subprocess import check_output - -status = check_output(['acpi'], universal_newlines=True) - -if not status: - # stands for no battery found - fulltext = "<span font='FontAwesome'>\uf00d \uf240</span>" - percentleft = 100 -else: - # if there is more than one battery in one laptop, the percentage left is - # available for each battery separately, although state and remaining - # time for overall block is shown in the status of the first battery - batteries = status.split("\n") - state_batteries=[] - commasplitstatus_batteries=[] - percentleft_batteries=[] - time = "" - for battery in batteries: - if battery!='': - state_batteries.append(battery.split(": ")[1].split(", ")[0]) - commasplitstatus = battery.split(", ") - if not time: - time = commasplitstatus[-1].strip() - # check if it matches a time - time = re.match(r"(\d+):(\d+)", time) - if time: - time = ":".join(time.groups()) - timeleft = " ({})".format(time) - else: - timeleft = "" - - p = int(commasplitstatus[1].rstrip("%\n")) - if p>0: - percentleft_batteries.append(p) - commasplitstatus_batteries.append(commasplitstatus) - state = state_batteries[0] - commasplitstatus = commasplitstatus_batteries[0] - if percentleft_batteries: - percentleft = int(sum(percentleft_batteries)/len(percentleft_batteries)) - else: - percentleft = 0 - - # stands for charging - FA_LIGHTNING = "<span font='FontAwesome'>\uf0e7</span>" - - # stands for plugged in - FA_PLUG = "<span font='FontAwesome'>\uf1e6</span>" - - # stands for using battery - FA_BATTERY = "<span font='FontAwesome'>\uf240</span>" - - # stands for unknown status of battery - FA_QUESTION = "<span font='FontAwesome'>\uf128</span>" - - - if state == "Discharging": - fulltext = FA_BATTERY + " " - elif state == "Full": - fulltext = FA_PLUG + " " - timeleft = "" - elif state == "Unknown": - fulltext = FA_QUESTION + " " + FA_BATTERY + " " - timeleft = "" - else: - fulltext = FA_LIGHTNING + " " - - def color(percent): - if percent < 10: - # exit code 33 will turn background red - return "#FFFFFF" - if percent < 20: - return "#FF3300" - if percent < 30: - return "#FFFF00" - return "#FFFFFF" - - form = '<span color="{}">{}%</span>' - fulltext += str(percentleft) + timeleft - if color(percentleft) != "#FFFFFF": - fulltext = form.format(color(percentleft), fulltext) - -print(fulltext) -print(fulltext) -if percentleft < 10: - exit(33) diff --git a/.config/i3blocks/bin/disk b/.config/i3blocks/bin/disk @@ -1,4 +0,0 @@ -#!/usr/bin/env sh - -#echo -n "<span font='FontAwesome'> </span> "; df -h -l --output='used' "$HOME" | grep -E -o '[0-9]+G' -echo -n "<span font='FontAwesome'> </span> "; df -h -l --output='avail' "$HOME" | grep -E -o '[0-9]+G' diff --git a/.config/i3blocks/bin/volume-pulseaudio b/.config/i3blocks/bin/volume-pulseaudio @@ -1,182 +0,0 @@ -#!/bin/bash -# Displays the default device, volume, and mute status for i3blocks - -set -a - -AUDIO_HIGH_SYMBOL=${AUDIO_HIGH_SYMBOL:-"<span font='FontAwesome'></span>"} - -AUDIO_MED_THRESH=${AUDIO_MED_THRESH:-50} -AUDIO_MED_SYMBOL=${AUDIO_MED_SYMBOL:-"<span font='FontAwesome'></span>"} - -AUDIO_LOW_THRESH=${AUDIO_LOW_THRESH:-0} -AUDIO_LOW_SYMBOL=${AUDIO_LOW_SYMBOL:-"<span font='FontAwesome'></span>"} - -AUDIO_MUTED_SYMBOL=${AUDIO_MUTED_SYMBOL:-"<span font='FontAwesome'></span>"} - -AUDIO_DELTA=${AUDIO_DELTA:-5} - -DEFAULT_COLOR=${DEFAULT_COLOR:-"#ffffff"} -MUTED_COLOR=${MUTED_COLOR:-"#a0a0a0"} - -LONG_FORMAT=${LONG_FORMAT:-'${SYMB} ${VOL}%'} -SHORT_FORMAT=${SHORT_FORMAT:-'${SYMB} ${VOL}% [${INDEX}]'} -MUTED_FORMAT=${MUTED_FORMAT:-'${SYMB}'} -USE_ALSA_NAME=${USE_ALSA_NAME:-0} -USE_DESCRIPTION=${USE_DESCRIPTION:-0} - -SUBSCRIBE=${SUBSCRIBE:-0} - -MIXER=${MIXER:-""} -SCONTROL=${SCONTROL:-""} - -while getopts F:Sf:adH: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" ;; - 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, with exposed variables: -\${SYMB}, \${VOL}, \${INDEX}, \${NAME} --S\tSubscribe to volume events (requires persistent block, always uses long format) --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_DELTA --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_DELTA%+ ;; - 5) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_DELTA%- ;; -esac - -function print_format { - echo "$1" | envsubst '${SYMB}${VOL}${INDEX}${NAME}' -} - -function print_block { - ACTIVE=$(pacmd list-sinks | grep "state\: RUNNING" -B4 -A7 | grep "index:\|name:\|volume: \(front\|mono\)\|muted:") - [ -z "$ACTIVE" ] && ACTIVE=$(pacmd list-sinks | grep "index:\|name:\|volume: \(front\|mono\)\|muted:" | grep -A3 '*') - for name in INDEX NAME VOL MUTED; do - read $name - done < <(echo "$ACTIVE") - 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 - SYMB=$AUDIO_HIGH_SYMBOL - [[ $VOL -le $AUDIO_MED_THRESH ]] && SYMB=$AUDIO_MED_SYMBOL - [[ $VOL -le $AUDIO_LOW_THRESH ]] && SYMB=$AUDIO_LOW_SYMBOL - COLOR=$DEFAULT_COLOR - else - SYMB=$AUDIO_MUTED_SYMBOL - #COLOR=$MUTED_COLOR - COLOR=$DEFAULT_COLOR - fi - - if [[ $SUBSCRIBE == 1 ]] ; then - print_format "$LONG_FORMAT" - else - if [[ $MUTED =~ "no" ]] && [ $VOL != $AUDIO_LOW_THRESH ]; then - print_format "$LONG_FORMAT" - print_format "$SHORT_FORMAT" - else - print_format "$MUTED_FORMAT" - print_format "$MUTED_FORMAT" - fi -# echo "$COLOR" - fi -} - -print_block -if [[ $SUBSCRIBE == 1 ]] ; then - while read -r EVENT; do - print_block - done < <(pactl subscribe | stdbuf -oL grep change) -fi diff --git a/.config/i3blocks/config b/.config/i3blocks/config @@ -1,28 +0,0 @@ -separator_block_width=30 -markup=pango - -[disk] -command=$HOME/.config/i3blocks/bin/disk -interval=30 - -[updates] -command=$HOME/.config/i3blocks/bin/apt-updates -interval=3600 - -[backlight] -command=$HOME/.config/i3blocks/bin/backlight -interval=once -signal=2 - -[volume] -command=$HOME/.config/i3blocks/bin/volume-pulseaudio -interval=once -signal=1 - -[battery] -command=$HOME/.config/i3blocks/bin/battery2 -interval=30 - -[datetime] -command=date +"%a %d %b, %H:%M" -interval=5 diff --git a/.config/zsh/.zshenv b/.config/zsh/.zshenv @@ -1,5 +1,6 @@ # Local bin to path -[ -d "$HOME/.local/bin" ] && export PATH="$HOME/.local/bin:$PATH" +[ -d "$HOME/.local/bin" ] && \ + export PATH="$PATH:$(du "$HOME/.local/bin/" | cut -f2 | paste -sd ':')" # XDG dirs export XDG_DATA_HOME="$HOME/.local/share" diff --git a/.local/bin/dwmblocks/dwmb-apt-updates b/.local/bin/dwmblocks/dwmb-apt-updates @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +sudo apt-get update > /dev/null 2> /dev/null +UPDATES="$(apt-get upgrade -s |grep -P '^\d+ upgraded'|cut -d" " -f1)" +[ "0" != "$UPDATES" ] && echo " $UPDATES" diff --git a/.local/bin/dwmblocks/dwmb-backlight b/.local/bin/dwmblocks/dwmb-backlight @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +echo "☀ $(xbacklight -get)%" | sed "s/\.[0-9]*//g" diff --git a/.local/bin/dwmblocks/dwmb-battery2 b/.local/bin/dwmblocks/dwmb-battery2 @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 James Murphy +# Licensed under the GPL version 2 only +# +# A battery indicator blocklet script for i3blocks + +import re +from subprocess import check_output + +status = check_output(['acpi'], universal_newlines=True) + +if not status: + # stands for no battery found + fulltext = "\uf00d \uf240" + percentleft = 100 +else: + # if there is more than one battery in one laptop, the percentage left is + # available for each battery separately, although state and remaining + # time for overall block is shown in the status of the first battery + batteries = status.split("\n") + state_batteries=[] + commasplitstatus_batteries=[] + percentleft_batteries=[] + time = "" + for battery in batteries: + if battery!='': + state_batteries.append(battery.split(": ")[1].split(", ")[0]) + commasplitstatus = battery.split(", ") + if not time: + time = commasplitstatus[-1].strip() + # check if it matches a time + time = re.match(r"(\d+):(\d+)", time) + if time: + time = ":".join(time.groups()) + timeleft = " ({})".format(time) + else: + timeleft = "" + + p = int(commasplitstatus[1].rstrip("%\n")) + if p>0: + percentleft_batteries.append(p) + commasplitstatus_batteries.append(commasplitstatus) + state = state_batteries[0] + commasplitstatus = commasplitstatus_batteries[0] + if percentleft_batteries: + percentleft = int(sum(percentleft_batteries)/len(percentleft_batteries)) + else: + percentleft = 0 + + # stands for charging + FA_LIGHTNING = "\uf0e7" + + # stands for plugged in + FA_PLUG = "\uf1e6" + + # stands for using battery + FA_BATTERY = "\uf240" + + # stands for unknown status of battery + FA_QUESTION = "\uf128" + + + if state == "Discharging": + fulltext = FA_BATTERY + " " + elif state == "Full": + fulltext = FA_PLUG + " " + timeleft = "" + elif state == "Unknown": + fulltext = FA_QUESTION + " " + FA_BATTERY + " " + timeleft = "" + else: + fulltext = FA_LIGHTNING + " " + + fulltext += str(percentleft) + "%" + timeleft + +print(fulltext) +print(fulltext) +if percentleft < 10: + exit(33) diff --git a/.local/bin/dwmblocks/dwmb-date b/.local/bin/dwmblocks/dwmb-date @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +date +"%a %d %b, %H:%M" diff --git a/.local/bin/dwmblocks/dwmb-disk b/.local/bin/dwmblocks/dwmb-disk @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +#echo -n " "; df -h -l --output='used' "$HOME" | grep -E -o '[0-9]+G' +echo -n " "; df -h -l --output='avail' "$HOME" | grep -E -o '[0-9]+G' diff --git a/.local/bin/dwmblocks/dwmb-volume b/.local/bin/dwmblocks/dwmb-volume @@ -0,0 +1,182 @@ +#!/bin/bash +# Displays the default device, volume, and mute status for i3blocks + +set -a + +AUDIO_HIGH_SYMBOL=${AUDIO_HIGH_SYMBOL:-""} + +AUDIO_MED_THRESH=${AUDIO_MED_THRESH:-50} +AUDIO_MED_SYMBOL=${AUDIO_MED_SYMBOL:-""} + +AUDIO_LOW_THRESH=${AUDIO_LOW_THRESH:-0} +AUDIO_LOW_SYMBOL=${AUDIO_LOW_SYMBOL:-""} + +AUDIO_MUTED_SYMBOL=${AUDIO_MUTED_SYMBOL:-""} + +AUDIO_DELTA=${AUDIO_DELTA:-5} + +DEFAULT_COLOR=${DEFAULT_COLOR:-"#ffffff"} +MUTED_COLOR=${MUTED_COLOR:-"#a0a0a0"} + +LONG_FORMAT=${LONG_FORMAT:-'${SYMB} ${VOL}%'} +SHORT_FORMAT=${SHORT_FORMAT:-'${SYMB} ${VOL}% [${INDEX}]'} +MUTED_FORMAT=${MUTED_FORMAT:-'${SYMB}'} +USE_ALSA_NAME=${USE_ALSA_NAME:-0} +USE_DESCRIPTION=${USE_DESCRIPTION:-0} + +SUBSCRIBE=${SUBSCRIBE:-0} + +MIXER=${MIXER:-""} +SCONTROL=${SCONTROL:-""} + +while getopts F:Sf:adH: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" ;; + 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, with exposed variables: +\${SYMB}, \${VOL}, \${INDEX}, \${NAME} +-S\tSubscribe to volume events (requires persistent block, always uses long format) +-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_DELTA +-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_DELTA%+ ;; + 5) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_DELTA%- ;; +esac + +function print_format { + echo "$1" | envsubst '${SYMB}${VOL}${INDEX}${NAME}' +} + +function print_block { + ACTIVE=$(pacmd list-sinks | grep "state\: RUNNING" -B4 -A7 | grep "index:\|name:\|volume: \(front\|mono\)\|muted:") + [ -z "$ACTIVE" ] && ACTIVE=$(pacmd list-sinks | grep "index:\|name:\|volume: \(front\|mono\)\|muted:" | grep -A3 '*') + for name in INDEX NAME VOL MUTED; do + read $name + done < <(echo "$ACTIVE") + 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 + SYMB=$AUDIO_HIGH_SYMBOL + [[ $VOL -le $AUDIO_MED_THRESH ]] && SYMB=$AUDIO_MED_SYMBOL + [[ $VOL -le $AUDIO_LOW_THRESH ]] && SYMB=$AUDIO_LOW_SYMBOL + COLOR=$DEFAULT_COLOR + else + SYMB=$AUDIO_MUTED_SYMBOL + #COLOR=$MUTED_COLOR + COLOR=$DEFAULT_COLOR + fi + + if [[ $SUBSCRIBE == 1 ]] ; then + print_format "$LONG_FORMAT" + else + if [[ $MUTED =~ "no" ]] && [ $VOL != $AUDIO_LOW_THRESH ]; then + print_format "$LONG_FORMAT" + print_format "$SHORT_FORMAT" + else + print_format "$MUTED_FORMAT" + print_format "$MUTED_FORMAT" + fi +# echo "$COLOR" + fi +} + +print_block +if [[ $SUBSCRIBE == 1 ]] ; then + while read -r EVENT; do + print_block + done < <(pactl subscribe | stdbuf -oL grep change) +fi diff --git a/.local/bin/i3-lock b/.local/bin/i3-lock @@ -1,16 +0,0 @@ -#!/usr/bin/env sh - -XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-"$HOME/.config"} -XDG_CACHE_HOME=${XDG_CACHE_HOME:-"$HOME/.cache"} - -DIMS="$(xdpyinfo | grep dimensions | awk '{print $2}')" -WALL="$XDG_CONFIG_HOME/i3/wallpaper.png" -OUTDIR="$XDG_CACHE_HOME/i3/wallpapers" -OUT="$OUTDIR/$DIMS.png" - -[ -f "$OUT" ] && i3lock -i "$OUT" && sleep 0.3 && xset dpms force off && exit -[ ! -f "$WALL" ] && i3lock -c 142a3a && sleep 0.3 && xset dpms force off && exit -[ ! -d "$OUTDIR" ] && mkdir --parents $OUTDIR -convert -resize "$DIMS^" -gravity center -extent "$DIMS" $WALL $OUT -i3lock -i "$OUT" -sleep 0.3 && xset dpms force off && exit diff --git a/.local/share/dwm/autostart.sh b/.local/share/dwm/autostart.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +xautolock -detectsleep -corners 0-00 -time 5 \ + -locker "slock" \ + -notify 30 \ + -notifier "notify-send -u critical -t 10000 'Locking screen in 30 seconds'" & + +# set wallpaper +xwallpaper --zoom "${XDG_DATA_HOME:-$HOME/.local/share}/dwm/wallpaper.png" & + +# use caps as super +setxkbmap -option 'caps:super' & + +# tap caps for escape (hold down for super) +xcape -e 'Super_L=Escape' & + +# activate num lock +numlockx & + +# configure monitors +$HOME/.local/bin/configure-monitors & + +xsetroot -name "$(date +"%a %d %b, %H:%M")" & +dwmblocks &