diff options
| -rw-r--r-- | .bash_profile | 3 | ||||
| -rw-r--r-- | .bashrc | 13 | ||||
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | README.md (renamed from README) | 17 | ||||
| -rw-r--r-- | configs/i3/config | 217 | ||||
| -rwxr-xr-x | configs/i3/format_displays.sh | 83 | ||||
| -rw-r--r-- | configs/i3/i3blocks/config | 48 | ||||
| -rwxr-xr-x | configs/i3/i3blocks/scripts/archupdates | 10 | ||||
| -rwxr-xr-x | configs/i3/i3blocks/scripts/bandwidth | 88 | ||||
| -rwxr-xr-x | configs/i3/i3blocks/scripts/battery | 29 | ||||
| -rwxr-xr-x | configs/i3/i3blocks/scripts/brightness | 10 | ||||
| -rwxr-xr-x | configs/i3/i3blocks/scripts/calendar | 40 | ||||
| -rwxr-xr-x | configs/i3/i3blocks/scripts/volume | 70 | ||||
| -rwxr-xr-x | configs/i3/i3lock.sh | 6 | ||||
| -rwxr-xr-x | scripts/change_brightness | bin | 0 -> 18240 bytes | |||
| -rwxr-xr-x | setup.sh | 2 |
16 files changed, 635 insertions, 2 deletions
diff --git a/.bash_profile b/.bash_profile index 39575e2..fef0e14 100644 --- a/.bash_profile +++ b/.bash_profile @@ -1,6 +1,9 @@ # # ~/.bash_profile # +PATH=$PATH:$HOME/.cargo/bin +PATH=$PATH:$HOME/go/bin +export PATH [[ -f ~/.bashrc ]] && . ~/.bashrc @@ -10,6 +10,11 @@ function parse_git_branch () { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } +# mkdir and follow into dir +function mkdirf () { + mkdir -p $1 && cd $1 +} + # Customize prompt if [ -n "$SSH_CLIENT" ]; then ssh_text="ssh" fi @@ -31,9 +36,11 @@ alias etags='etags .*{c,C,cc,cpp,h,hh,hpp,cpp}' alias r='rg' alias grep='grep --color' alias g='googler' +alias pt='prototool' +alias t='tmux' export ALTERNATE_EDITOR="" -export EDITOR=vim +export EDITOR="vim" export VISUAL=emacs # NOTE: These env vars happen to be wanted. This also happens to fix a weird bug (just for reference): @@ -64,7 +71,7 @@ elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then alias ls='ls --color=auto' # Setup keychain - /usr/bin/keychain $HOME/.ssh/id_rsa $HOME/.ssh/id_ed25519 $HOME/.ssh/nido_id_ed25519 + /usr/bin/keychain $HOME/.ssh/id_rsa $HOME/.ssh/id_ed25519 /usr/bin/keychain --agents gpg AE38865D . $HOME/.keychain/${HOSTNAME}-sh . $HOME/.keychain/${HOSTNAME}-sh-gpg @@ -87,3 +94,5 @@ fi source ~/.setup/.git-completion.bash source /usr/local/arcanist/resources/shell/bash-completion source ~/.setup/.bashrc.local + +complete -C /usr/bin/vault vault @@ -1 +1,2 @@ .*.local +/scripts/*.c @@ -8,6 +8,23 @@ Run setup.sh for a bare minimal setup. ## Things to do +### $PROJ_DIR/scripts + +General scripts should be installed/symlinked into `/usr/local/bin` + +i3blocks scripts should be installed/symlinked into `/usr/local/i3blocks/` + +``` +for i in $(ls ~/.setup/configs/i3/i3blocks/scripts); do sudo ln -s ~/.setup/configs/i3/i3blocks/scripts/$i $i; done +``` + +### Udev Rules +https://wiki.archlinux.org/index.php/Udev + +When using i3wm, it's nice to have external displays automatically detected. Since /sys isn't a real filesystem, inotifywait has no guarantees. Thus, we write a udev rule which points to our `$PROJ_DIR/i3/format_displays.sh` script. + +_TODO_ + #### Suggested Applications These application packages are based on the packages from [archlinux.org](https://www.archlinux.org/packages/). Each distro will vary. diff --git a/configs/i3/config b/configs/i3/config new file mode 100644 index 0000000..e709703 --- /dev/null +++ b/configs/i3/config @@ -0,0 +1,217 @@ +# This file has been auto-generated by i3-config-wizard(1). +# It will not be overwritten, so edit it as you like. +# +# Should you change your keyboard layout some time, delete +# this file and re-run i3-config-wizard(1). +# +# i3 config file (v4) +# +# Please see https://i3wm.org/docs/userguide.html for a complete reference! + +set $mod Mod4 + +# Font for window titles. Will also be used by the bar unless a different font +# is used in the bar {} block below. +font pango:monospace 8 + +# This font is widely installed, provides lots of unicode glyphs, right-to-left +# text rendering and scalability on retina/hidpi displays (thanks to pango). +# font pango:DejaVu Sans Mono 8 +font pango:Source Code Pro 8 + +# Background +exec --no-startup-id feh --bg-fill ~/pictures/Yosemite-Color-Block.png + +# Compositor +exec --no-startup-id compton --config ~/.config/compton.conf -b + +# The combination of xss-lock, nm-applet and pactl is a popular choice, so +# they are included here as an example. Modify as you see fit. + +# Lock screen with i3lock and custom wallpaper +exec --no-startup-id /usr/local/bin/i3lock + +## Allow yad to float for i3bar calendar +for_window [class="Yad"] floating enable + +# NetworkManager is the most popular way to manage wireless networks on Linux, +# and nm-applet is a desktop environment-independent system tray GUI for it. +exec --no-startup-id nm-applet + +# Use pactl to adjust volume in PulseAudio. +bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% && pkill -SIGRTMIN+10 i3blocks +bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% && pkill -SIGRTMIN+10 i3blocks +bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && pkill -SIGRTMIN+10 i3blocks + +# Use change_brightness (in .setup dir) to adjust backlight +bindsym XF86MonBrightnessUp exec --no-startup-id change_brightness -i 50 && pkill -SIGRTMIN+9 i3blocks +bindsym XF86MonBrightnessDown exec --no-startup-id change_brightness -d 50 && pkill -SIGRTMIN+9 i3blocks + +# Use format_displays (in .setup dir) to configure external displays +bindsym XF86LaunchA exec --no-startup-id format_displays + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod + +# start a terminal +bindsym $mod+Return exec urxvt + +# kill focused window +bindsym $mod+q kill + +# start dmenu (a program launcher) +# bindsym $mod+space exec --no-startup-id dmenu_run +# There also is the (new) i3-dmenu-desktop which only displays applications +# shipping a .desktop file. It is a wrapper around dmenu, so you need that +# installed. +# bindsym $mod+space exec --no-startup-id i3-dmenu-desktop +bindsym $mod+space exec --no-startup-id rofi -lines 5 -padding 18 -width 60 -location 0 -show drun -sidebar-mode -columns 3 -font 'Source Code Pro 18' +bindsym $mod+Tab exec --no-startup-id rofi -lines 5 -padding 18 -width 60 -location 0 -show window -sidebar-mode -columns 4 -font 'Source Code Pro 18' + +# 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 + +# split in horizontal orientation +bindsym $mod+equal split h + +# split in vertical orientation +bindsym $mod+Shift+equal split v + +# 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+w layout tabbed +bindsym $mod+e layout toggle split + +# toggle tiling / floating +bindsym $mod+Shift+d floating toggle + +# change focus between tiling / floating windows +bindsym $mod+d focus mode_toggle + +# focus the parent container +bindsym $mod+a focus parent + +# focus the child container +#bindsym $mod+d focus child + +# Define names for default workspaces for which we configure key bindings later on. +# 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 +bindsym $mod+Shift+1 move container to workspace $ws1 +bindsym $mod+Shift+2 move container to workspace $ws2 +bindsym $mod+Shift+3 move container to workspace $ws3 +bindsym $mod+Shift+4 move container to workspace $ws4 +bindsym $mod+Shift+5 move container to workspace $ws5 +bindsym $mod+Shift+6 move container to workspace $ws6 +bindsym $mod+Shift+7 move container to workspace $ws7 +bindsym $mod+Shift+8 move container to workspace $ws8 +bindsym $mod+Shift+9 move container to workspace $ws9 +bindsym $mod+Shift+0 move container to workspace $ws10 + +# 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 +# exit i3 (logs you out of your X 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'" + +# fullscreen videos to small sticky in corner +bindsym $mod+y fullscreen disable; floating enable; resize set 844 480; sticky enable; move position 870 25 + +# resize window (you can also use the mouse for that) +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 10 px or 10 ppt + bindsym j resize grow height 10 px or 10 ppt + bindsym k resize shrink height 10 px or 10 ppt + bindsym l resize grow width 10 px or 10 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" + +# Start i3bar to display a workspace bar (plus the system information i3status +# finds out, if available) + +# custom bindings for i3blocks +bar { + status_command i3blocks + i3bar_command i3bar -t + + font pango:Font Awesome,Source Code Pro 9 + + position bottom + mode dock + colors { + statusline #76c2d6 + background #1d2021A0 + + # Type border background text + focused_workspace #191919 #191919 #bf3f34 + active_workspace #191919 #191919 #696f89 + inactive_workspace #191919 #191919 #696f89 + urgent_workspace #191919 #191919 #c7a551 + } +} diff --git a/configs/i3/format_displays.sh b/configs/i3/format_displays.sh new file mode 100755 index 0000000..68279d7 --- /dev/null +++ b/configs/i3/format_displays.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +# get the displays which are connected and setup an associative array +DISPLAYS=( $(xrandr | grep " connected" | awk '{print $1}') ) +declare -A DISP_RES + +BG_IMG="~/pictures/Yosemite-Color-Block.png" + +VERBOSE="" +if_echo () { + if [ -n "$VERBOSE" ]; then + echo $1 + fi +} + +while getopts ":h" opt; do + case ${opt} in + h ) VERBOSE="on" + ;; + \? ) echo "read the script for help; -v for verbose logging" + ;; + esac +done + +for (( i=0; i <${#DISPLAYS[@]}; i++ )); do + # store the assocated resolutions + DISPLAY_NAME=${DISPLAYS[i]} + DISP_RES["$DISPLAY_NAME"]=$(xrandr | grep "^$DISPLAY_NAME" -A 1 | tail -n 1 | awk '{print $1}') +done + +# We setup a consistent monitor ordering as follows... +# ----- ----- ------ ------ +# | DP-1 | | DP-2 | | HDMI-1 | | HDMI-2 | +# ----- ----- ------ ------ +# \ \ / / +# \ | | / +# \ ----- / +# \ | eDP-1 |----/ +# _____ + +EDP_1=${DISP_RES["eDP-1"]} +DP_1=${DISP_RES["DP-1"]} +DP_2=${DISP_RES["DP-2"]} +HDMI_1=${DISP_RES["HDMI-1"]} + +if [ -n "$EDP_1" ]; then + # if no other displays are set, then we bring all windows into eDP-1 + if [[ -z "$DP_1" && -z "$DP_2" && -z "$HDMI_1" ]]; then + if_echo "No displays detected. Resetting primary display (eDP-1)" + xrandr --auto + else + if_echo "Found other displays, and explicitly setting primary display (eDP-1)" + xrandr --output eDP-1 --mode "$EDP_1" + fi +fi + +if [ -n "$DP_1" ]; then + if_echo "Found DP-1. Setting DP-1 above primary display (eDP-1)" + xrandr --output DP-1 --mode "$DP_1" --above eDP-1 +fi + +if [[ -n "$DP_2" && -n "$DP_1" ]]; then + if_echo "Found DP-2. Setting DP-2 right of DP-1" + xrandr --output DP-2 --mode "$DP_2" --right-of DP-1 +elif [[ -n "$DP_2" ]]; then + if_echo "Found DP-2 but not DP-1. Setting DP-2 above primary display (eDP-1)" + xrandr --output DP-2 --mode "$DP_2" --above eDP-1 +fi + +if [[ -n "$HDMI_1" && -n "$DP_2" && "$DP_1" ]]; then + if_echo "Found HDMI-1. Setting it right of DP-2" + xrandr --output HDMI-1 --mode "$HDMI_1" --right-of DP-2 +elif [[ -n "$HDMI_1" && ( "$DP_2" || "$DP_1" ) ]]; then + if [ -n "$DP_2" ]; then + if_echo "Found HDMI-1 and DP-2 but not DP-1. Setting HDMI-1 right of DP-2" + xrandr --output HDMI-1 --mode "$HDMI_1" --right-of DP-2 + else + if_echo "Found HDMI-1 and DP-1 but not DP-2. Setting HDMI-1 right of DP-1" + xrandr --output HDMI-1 --mode "$HDMI_1" --right-of DP-1 + fi +fi + +feh bg-fill "$IMG" diff --git a/configs/i3/i3blocks/config b/configs/i3/i3blocks/config new file mode 100644 index 0000000..34a7aef --- /dev/null +++ b/configs/i3/i3blocks/config @@ -0,0 +1,48 @@ +command=/usr/lib/i3blocks/$BLOCK_NAME +separator=false +separator_block_width=15 +markup=pango + +[battery] +command=/usr/local/i3blocks/$BLOCK_NAME +interval=1 +color=#eee8d5 + +[brightness] +command=/usr/local/i3blocks/$BLOCK_NAME +interval=once +signal=9 +color=#ffff33 + +[volume] +command=/usr/local/i3blocks/$BLOCK_NAME +instance=Master +interval=once +signal=10 +color=#4ca2df + +[bandwidth] +command=/usr/local/i3blocks/$BLOCK_NAME +instance=wlp3s0 +interval=1 +# color=#859900 + +[memory] +label= +interval=1 +color=#e6ccff + +[temperature] +label= +interval=10 +color=#cb4b16 + +[archupdates] +command=/usr/local/i3blocks/$BLOCK_NAME +interval=60 +color=#49E20E + +[calendar] +command=/usr/local/i3blocks/calendar +interval=60 +color=#ffffff diff --git a/configs/i3/i3blocks/scripts/archupdates b/configs/i3/i3blocks/scripts/archupdates new file mode 100755 index 0000000..c07c45f --- /dev/null +++ b/configs/i3/i3blocks/scripts/archupdates @@ -0,0 +1,10 @@ +#!/usr/bin/bash + +PAC_UPDATES=$(checkupdates | wc -l) +AUR_UPDATES=$(cower -u | wc -l) + +if [[ $PAC_UPDATES -gt 0 || $AUR_UPDATES -gt 0 ]]; then + echo " [$PAC_UPDATES .. $AUR_UPDATES]" +else + echo "<span color=\"#586e75\"> 0</span>" +fi
\ No newline at end of file diff --git a/configs/i3/i3blocks/scripts/bandwidth b/configs/i3/i3blocks/scripts/bandwidth new file mode 100755 index 0000000..d7db2a6 --- /dev/null +++ b/configs/i3/i3blocks/scripts/bandwidth @@ -0,0 +1,88 @@ +#!/bin/bash +# Copyright (C) 2012 Stefan Breunig <stefan+measure-net-speed@mathphys.fsk.uni-heidelberg.de> +# Copyright (C) 2014 kaueraal +# Copyright (C) 2015 Thiago Perrotta <perrotta dot thiago at poli dot ufrj dot br> + +# 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/>. + +# Use the provided interface, otherwise the device used for the default route. +if [[ -n $BLOCK_INSTANCE ]]; then + INTERFACE=$BLOCK_INSTANCE +else + INTERFACE=$(ip route | awk '/^default/ { print $5 ; exit }') +fi + +# Issue #36 compliant. +if ! [ -e "/sys/class/net/${INTERFACE}/operstate" ] || ! [ "`cat /sys/class/net/${INTERFACE}/operstate`" = "up" ] +then + echo "$INTERFACE down" + echo "$INTERFACE down" + echo "#FF0000" + exit 0 +fi + +# path to store the old results in +path="/dev/shm/$(basename $0)-${INTERFACE}" + +# grabbing data for each adapter. +read rx < "/sys/class/net/${INTERFACE}/statistics/rx_bytes" +read tx < "/sys/class/net/${INTERFACE}/statistics/tx_bytes" + +# get time +time=$(date +%s) + +# write current data if file does not exist. Do not exit, this will cause +# problems if this file is sourced instead of executed as another process. +if ! [[ -f "${path}" ]]; then + echo "${time} ${rx} ${tx}" > "${path}" + chmod 0666 "${path}" +fi + +# read previous state and update data storage +read old < "${path}" +echo "${time} ${rx} ${tx}" > "${path}" + +# parse old data and calc time passed +old=(${old//;/ }) +time_diff=$(( $time - ${old[0]} )) + +# sanity check: has a positive amount of time passed +[[ "${time_diff}" -gt 0 ]] || exit + +# calc bytes transferred, and their rate in byte/s +rx_diff=$(( $rx - ${old[1]} )) +tx_diff=$(( $tx - ${old[2]} )) +rx_rate=$(( $rx_diff / $time_diff )) +tx_rate=$(( $tx_diff / $time_diff )) + +# shift by 10 bytes to get KiB/s. If the value is larger than +# 1024^2 = 1048576, then display MiB/s instead + +# incoming +echo -n "⇘" +rx_kib=$(( $rx_rate >> 10 )) +if [[ "$rx_rate" -gt 1048576 ]]; then + printf '%sM' "`echo "scale=1; $rx_kib / 1024" | bc`" +else + echo -n "${rx_kib}K" +fi + +# outgoing +echo -n "<span color=\"#93a1a1\">⇖</span>" +tx_kib=$(( $tx_rate >> 10 )) +if [[ "$tx_rate" -gt 1048576 ]]; then + printf '%sM' "`echo "scale=1; $tx_kib / 1024" | bc`" +else + echo -n "<span color=\"#93a1a1\">${tx_kib}K</span>" +fi diff --git a/configs/i3/i3blocks/scripts/battery b/configs/i3/i3blocks/scripts/battery new file mode 100755 index 0000000..802689b --- /dev/null +++ b/configs/i3/i3blocks/scripts/battery @@ -0,0 +1,29 @@ +#!/usr/bin/bash + +BAT_DIR=/sys/class/power_supply/BAT0 +CHARGE=$(cat $BAT_DIR/capacity) +CHARGE_FULL=$(cat $BAT_DIR/charge_full) +CHARGE_NOW=$(cat $BAT_DIR/charge_now) +STATUS=$(cat $BAT_DIR/status) + +ICON_BATTERY_25_P= +ICON_BATTERY_50_P= +ICON_BATTERY_75_P= +ICON_BATTERY_FULL= +ICON_BATTERY_CHARGING= +ICON_FULL= + +PERCENT_FULL=$(echo - | awk -v charge_full="$CHARGE_FULL" -v charge_now="$CHARGE_NOW" '{printf "%1.0f\n", (charge_now / charge_full)*100}') +if [[ $STATUS == "Full" ]]; then + echo "$ICON_FULL" +elif [[ $STATUS == "Charging" ]]; then + echo "$ICON_BATTERY_CHARGING ($PERCENT_FULL%)" +elif [[ $PERCENT_FULL -lt 100 ]]; then + echo "$ICON_BATTERY_FULL ($PERCENT_FULL%)" +elif [[ $PERCENT_FULL -lt 75 ]]; then + echo "$ICON_BATTERY_75_P ($PERCENT_FULL%)" +elif [[ $PERCENT_FULL -lt 50 ]]; then + echo "$ICON_BATTERY_50_P ($PERCENT_FULL%)" +elif [[ $PERCENT_FULL -lt 25 ]]; then + echo "$ICON_BATTERY_25_P ($PERCENT_FULL%)" +fi diff --git a/configs/i3/i3blocks/scripts/brightness b/configs/i3/i3blocks/scripts/brightness new file mode 100755 index 0000000..64ea1d8 --- /dev/null +++ b/configs/i3/i3blocks/scripts/brightness @@ -0,0 +1,10 @@ +#!/usr/bin/bash + +BRIGHTNESS_DIR=/sys/class/backlight/intel_backlight +MAX_BRIGHTNESS=$(cat $BRIGHTNESS_DIR/max_brightness) +CURR_BRIGHTNESS=$(cat $BRIGHTNESS_DIR/actual_brightness) + +ICON_BRIGHT_SUN="☀" +BRIGHTNESS_P=$(echo - | awk -v max="$MAX_BRIGHTNESS" -v curr="$CURR_BRIGHTNESS" '{printf "%1.0f\n", (curr / max)*100}') + +echo "$ICON_BRIGHT_SUN $BRIGHTNESS_P%" diff --git a/configs/i3/i3blocks/scripts/calendar b/configs/i3/i3blocks/scripts/calendar new file mode 100755 index 0000000..7ad0363 --- /dev/null +++ b/configs/i3/i3blocks/scripts/calendar @@ -0,0 +1,40 @@ +#! /bin/sh + +WIDTH=${WIDTH:-100} +HEIGHT=${HEIGHT:-100} +DATEFMT=${DATEFMT:-"+%Y-%M-%d %H:%m"} +SHORTFMT=${SHORTFMT:-"+%H:%M:%S"} + +OPTIND=1 +while getopts ":f:W:H:" opt; do + case $opt in + f) DATEFMT="$OPTARG" ;; + W) WIDTH="$OPTARG" ;; + H) HEIGHT="$OPTARG" ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + esac +done + +case "$BLOCK_BUTTON" in + 1|2|3) + + # the position of the upper left corner of the popup + posX=$(( ( $BLOCK_X - 230 ) - $WIDTH / 2 )) + posY=$(( ( $BLOCK_Y - 200 ) - $HEIGHT )) + + i3-msg -q "exec yad --calendar \ + --width=$WIDTH --height=$HEIGHT \ + --undecorated --fixed \ + --close-on-unfocus --no-buttons \ + --posx=$posX --posy=$posY \ + > /dev/null" +esac +echo "$LABEL$(date "$DATEFMT") " +echo "$LABEL$(date "$SHORTFMT") " diff --git a/configs/i3/i3blocks/scripts/volume b/configs/i3/i3blocks/scripts/volume new file mode 100755 index 0000000..1e318a0 --- /dev/null +++ b/configs/i3/i3blocks/scripts/volume @@ -0,0 +1,70 @@ +#!/bin/bash +# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info> +# Copyright (C) 2014 Alexander Keller <github@nycroth.com> + +# 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/>. + +#------------------------------------------------------------------------ + +# 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}" + +# 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 + )}" + +# 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:-5%}" + +#------------------------------------------------------------------------ + +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" ? " MUTE" : "' + # If dB was selected, print that instead + perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo ' $1') + perl_filter+='"; exit}' + perl -ne "$perl_filter" +} + +#------------------------------------------------------------------------ + +case $BLOCK_BUTTON in + 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 + +volume | format diff --git a/configs/i3/i3lock.sh b/configs/i3/i3lock.sh new file mode 100755 index 0000000..822451d --- /dev/null +++ b/configs/i3/i3lock.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +IMG="~/pictures/Yosemite-Color-Block.png" + +xautolock -time 1 -locker "i3lock -i $IMG" -notify 20 -notifier 'xset dpms force off' & +xautolock -time 10 -locker "systemctl suspend" & diff --git a/scripts/change_brightness b/scripts/change_brightness Binary files differnew file mode 100755 index 0000000..49baa40 --- /dev/null +++ b/scripts/change_brightness @@ -30,6 +30,8 @@ for i in ${bash_files[@]}; do fi done +## TODO: symlink i3blocks scripts + if [ "$(uname)" = "Darwin" ]; then bash setup_brew.bash |
