diff --git a/dot_config/i3/conf.d/autostart.conf b/dot_config/i3/conf.d/autostart.conf new file mode 100644 index 0000000..8b26492 --- /dev/null +++ b/dot_config/i3/conf.d/autostart.conf @@ -0,0 +1,45 @@ +# vim: set fs=i3config + +#get auth work with polkit-gnome +exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 +# Run setup script +exec --no-startup-id ~/.config/i3/startup.sh +# Bluetooth applet +exec --no-startup-id blueman-tray +# Nextcloud sync +exec --no-startup-id nextcloud +# Compositor +exec --no-startup-id picom -b --config ~/.config/picom.conf +# Network Manager applet +exec --no-startup-id nm-applet +#set powersavings for display +exec --no-startup-id xset s 480 dpms 600 600 600 +# Desktop notifications +exec --no-startup-id /usr/bin/dunst +# screen lock +exec --no-startup-id /usr/bin/light-locker +# Mail notifications +# exec --no-startup-id thunderbird +# Joplin sync +exec --no-startup-id joplin-desktop +exec --no-startup-id nheko +exec --no-startup-id signal-desktop + +# File sync +exec --no-startup-id syncthing --no-browser + +# set powersavings for display: +# s 480: screensaver for 480s (I think) +# dpms 600 600 600: sets the delay in seconds before the Display Power +# Management Signalling kicks in. Each number configures standby, suspend, and +# off respectively, in seconds. +exec --no-startup-id xset s 480 dpms 600 600 600 + +# Sets the keyboard repeat speed +exec --no-startup-id xset r rate 150 40 + +# Set correct keyboard layout +exec --no-startup-id setxkbmap -layout us -variant altgr-intl +exec --no-startup-id tidal-hifi + +# exec --no-startup-id zeal diff --git a/dot_config/i3/conf.d/bar.conf b/dot_config/i3/conf.d/bar.conf new file mode 100644 index 0000000..5c57dc2 --- /dev/null +++ b/dot_config/i3/conf.d/bar.conf @@ -0,0 +1,23 @@ +# vim: set fs=i3config + +bar { + # status_command i3blocks -c ~/.config/i3/i3blocks.conf + status_command i3status-rs ~/.config/i3/i3status-rust.toml + # font pango:DejaVu Sans Mono, FontAwesome 11 + position bottom + tray_output primary + mode hide + hidden_state hide + modifier none + colors { + separator #666666 + background #222222 + statusline #dddddd + focused_workspace #0088CC #0088CC #ffffff + active_workspace #333333 #333333 #ffffff + inactive_workspace #333333 #333333 #888888 + urgent_workspace #2f343a #900000 #ffffff + } +} + +bindsym $mod+c bar hidden_state toggle diff --git a/dot_config/i3/conf.d/float_rules.conf b/dot_config/i3/conf.d/float_rules.conf new file mode 100644 index 0000000..9ec4c78 --- /dev/null +++ b/dot_config/i3/conf.d/float_rules.conf @@ -0,0 +1,19 @@ +# vim: set fs=i3config + +# =====FLOAT RULES===== +for_window [class="Yad" instance="yad"] floating enable +for_window [class="Galculator" instance="galculator"] floating enable +for_window [class="Xsane" instance="xsane"] floating enable +for_window [class="Pavucontrol" instance="pavucontrol"] floating enable +for_window [class="qt5ct" instance="qt5ct"] floating enable +for_window [class="Blueberry.py" instance="blueberry.py"] floating enable +for_window [class="Bluetooth-sendto" instance="bluetooth-sendto"] floating enable +for_window [class="Gufw.py" instance="gufw.py"] floating enable +for_window [class="Blueman-manager" instance="blueman-manager"] floating enable +for_window [class="firefox" window_role="PictureInPicture"] sticky enable +for_window [class="firefox" window_role="PictureInPicture"] border pixel + +for_window [class="tidal-hifi"] floating enable +for_window [class="tidal-hifi"] move to scratchpad + +for_window [class="Zeal" instance="zeal"] floating enable diff --git a/dot_config/i3/conf.d/keybinds.conf b/dot_config/i3/conf.d/keybinds.conf new file mode 100644 index 0000000..80808e7 --- /dev/null +++ b/dot_config/i3/conf.d/keybinds.conf @@ -0,0 +1,90 @@ +# vim: set fs=i3config + +# Mode for changing layout modes +mode "config" { + # Switch split mode + bindsym j split vertical; mode "default" + bindsym h split horizontal; mode "default" + bindsym k split vertical; mode "default" + bindsym l split horizontal; mode "default" + + # Switch layout + bindsym y layout stacking; mode "default" + bindsym u layout tabbed; mode "default" + bindsym i layout toggle split; mode "default" + + # Swap modifier key + bindsym s exec ~/.config/i3/swap_mod.sh; restart + + # Go back to normal mode + bindsym Escape mode "default" +} + +bindsym $mod+s mode "config" + +# Resize focused window +mode "resize" { + bindsym h resize shrink width 10 px or 10 ppt + bindsym j resize shrink height 10 px or 10 ppt + bindsym k resize grow height 10 px or 10 ppt + bindsym l resize grow width 10 px or 10 ppt + + bindsym Shift+h resize shrink width 2 px or 2 ppt + bindsym Shift+j resize shrink height 2 px or 2 ppt + bindsym Shift+k resize grow height 2 px or 2 ppt + bindsym Shift+l resize grow width 2 px or 2 ppt + + bindsym f floating toggle + bindsym s sticky toggle + + bindsym Escape mode "default" +} + +bindsym $mod+r mode "resize" + +# reload the configuration file +bindsym $mod+Shift+c reload + +# Restart i3 in-place +bindsym $mod+Shift+r restart + +# exit i3 (logs you out of your X session) +bindsym $mod+Shift+q 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'" + +# Volume +bindsym XF86AudioRaiseVolume exec amixer -D pulse sset Master 5%+ && pkill -RTMIN+1 i3blocks +bindsym XF86AudioLowerVolume exec amixer -D pulse sset Master 5%- && pkill -RTMIN+1 i3blocks +bindsym $mod+XF86AudioRaiseVolume exec amixer -D pulse sset Master 1%+ && pkill -RTMIN+1 i3blocks +bindsym $mod+XF86AudioLowerVolume exec amixer -D pulse sset Master 1%- && pkill -RTMIN+1 i3blocks +bindsym XF86AudioMute exec amixer -D pulse set Master toggle + +# Backlight +bindsym XF86MonBrightnessUp exec brightnessctl --device='intel_backlight' set +10% +bindsym XF86MonBrightnessDown exec brightnessctl --device='intel_backlight' set 10%- + +# Keyboard brightness +bindsym XF86KbdBrightnessUp exec brightnessctl --device='smc::kbd_backlight' set +10% +bindsym XF86KbdBrightnessDown exec brightnessctl --device='smc::kbd_backlight' set 10%- + +# Screenshot +bindsym --release Print exec "scrot -fis ~/Pictures/screenshots/%Y-%m-%d-%T.png" + +# Show shutdown menu +bindsym $mod+Escape exec ~/.config/i3/scripts/shutdown_menu -p rofi -c + + +# =====APPLICATIONS===== +# start a terminal +bindsym $mod+Return exec --no-startup-id st +# Open a Zeal window +bindsym $mod+w exec --no-startup-id zeal +# Launch output device configuration +bindsym $mod+m exec --no-startup-id pavucontrol -t 3 +# Open dmenu +bindsym $mod+d exec --no-startup-id i3-dmenu-desktop --dmenu dmenu +# Open Galculator +bindsym XF86Calculator exec --no-startup-id galculator +# Open tidal-hifi +# This keybindg is rather unusual as it should imply "move window to $wstidal", +# but because this workspace should only be used for tidal-hifi, it's okay. +bindsym $mod+n scratchpad show diff --git a/dot_config/i3/conf.d/workspaces.conf b/dot_config/i3/conf.d/workspaces.conf new file mode 100644 index 0000000..248f8f7 --- /dev/null +++ b/dot_config/i3/conf.d/workspaces.conf @@ -0,0 +1,134 @@ +# vim: set fs=i3config + +set $ws01 "" +set $ws02 "" +set $ws03 "" +set $ws04 "" +set $ws05 "" +# Workspace solely used for tidal-hifi +set $wstidal "T" +set $ws11 "α" +set $ws12 "β" +set $ws13 "γ" +set $ws14 "δ" +set $ws15 "ε" +set $ws21 "2:1" +set $ws22 "2:2" +set $ws23 "2:3" +set $ws24 "2:4" +set $ws25 "2:5" + +workspace $ws01 output primary +workspace $ws02 output primary +workspace $ws03 output primary +workspace $ws04 output primary +workspace $ws05 output primary +workspace $wstidal output primary +workspace $ws11 output eDP-1 +workspace $ws12 output eDP-1 +workspace $ws13 output eDP-1 +workspace $ws14 output eDP-1 +workspace $ws15 output eDP-1 +workspace $ws21 output HDMI-1 +workspace $ws22 output HDMI-1 +workspace $ws23 output HDMI-1 +workspace $ws24 output HDMI-1 +workspace $ws25 output HDMI-1 + +# =====WINDOW MANAGEMENT===== +# change focus +bindsym $mod+h focus left +bindsym $mod+j focus down +bindsym $mod+k focus up +bindsym $mod+l 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 + +# enter fullscreen mode for the focused container +bindsym $mod+f fullscreen toggle + +# kill focused window +bindsym $mod+x kill + +# toggle tiling / floating +bindsym $mod+Shift+space floating toggle +bindsym $mod+Ctrl+space sticky toggle + +# change focus between tiling / floating windows +bindsym $mod+space focus mode_toggle + +#resize floating windows with mouse scroll: +bindsym --whole-window --border $mod+button4 resize shrink height 5 px or 5 ppt +bindsym --whole-window --border $mod+button5 resize grow height 5 px or 5 ppt +bindsym --whole-window --border $mod+shift+button4 resize shrink width 5 px or 5 ppt +bindsym --whole-window --border $mod+shift+button5 resize grow width 5 px or 5 ppt + +# switch to main workspaces +bindsym $mod+y workspace $ws01 +bindsym $mod+u workspace $ws02 +bindsym $mod+i workspace $ws03 +bindsym $mod+o workspace $ws04 +bindsym $mod+p workspace $ws05 +# bindsym $mod+n workspace $wstidal + +# move focused container to main workspace +bindsym $mod+Shift+y move container to workspace $ws01 +bindsym $mod+Shift+u move container to workspace $ws02 +bindsym $mod+Shift+i move container to workspace $ws03 +bindsym $mod+Shift+o move container to workspace $ws04 +bindsym $mod+Shift+p move container to workspace $ws05 + +# Manage other workspaces +mode "eDP-1" { + # switch to workspace + bindsym y workspace $ws11 + bindsym u workspace $ws12 + bindsym i workspace $ws13 + bindsym o workspace $ws14 + bindsym p workspace $ws15 + + # move focused container to workspace + bindsym Shift+y move container to workspace $ws11 + bindsym Shift+u move container to workspace $ws12 + bindsym Shift+i move container to workspace $ws13 + bindsym Shift+o move container to workspace $ws14 + bindsym Shift+p move container to workspace $ws15 + + # Go to HDMI-0 mode + bindsym e mode "HDMI" + + # Go back to normal mode + bindsym Escape mode "default" +} + +mode "HDMI" { + # switch to workspace + bindsym y workspace $ws21 + bindsym u workspace $ws22 + bindsym i workspace $ws23 + bindsym o workspace $ws24 + bindsym p workspace $ws25 + + # move focused container to workspace + bindsym Shift+y move container to workspace $ws21 + bindsym Shift+u move container to workspace $ws22 + bindsym Shift+i move container to workspace $ws23 + bindsym Shift+o move container to workspace $ws24 + bindsym Shift+p move container to workspace $ws25 + + # Go to eDP-1-1 mode + bindsym e mode "eDP-1" + + # Go back to normal mode + bindsym Escape mode "default" +} + +bindsym $mod+e mode "eDP-1" + +# Force tidal-hifi to always spawn on $wstidal +# assign [class="tidal-hifi"] $wstidal +# no_focus [class="tidal-hifi"] diff --git a/dot_config/i3/executable_config b/dot_config/i3/executable_config new file mode 100644 index 0000000..3be18d4 --- /dev/null +++ b/dot_config/i3/executable_config @@ -0,0 +1,40 @@ +# =====GENERAL===== +# Main modifier; Mod1 is alt, Mod4 is Cmd/Windows +set $mod Mod1 + +# Modifier for floating-related operations +floating_modifier $mod + +# Layout for new workspaces; default means tiling +workspace_layout default + +#do not show titlebar on windows: +default_border pixel + +# thin borders +hide_edge_borders both + +# Size of gaps between windows +gaps inner 20 +gaps outer 10 + +# Font for window titles & bar, unless specified otherwise +font pango:Noto Sans Regular 8 + +# Include all other configuration files +include conf.d/*.conf + +# =====COLORS===== +set $bg-color #2f343f +set $inactive-bg-color #2f343f +set $text-color #f3f4f5 +set $inactive-text-color #676e7d +set $urgent-bg-color #e53935 +set $indicator-color #a0a0a0 + +# set window colors +# border background text indicator +client.focused $bg-color $bg-color $text-color $indicator-color +client.unfocused $inactive-bg-color $inactive-bg-color $inactive-text-color $indicator-color +client.focused_inactive $inactive-bg-color $inactive-bg-color $inactive-text-color $indicator-color +client.urgent $urgent-bg-color $urgent-bg-color $text-color $indicator-color diff --git a/dot_config/i3/executable_i3blocks.conf b/dot_config/i3/executable_i3blocks.conf new file mode 100644 index 0000000..78d5972 --- /dev/null +++ b/dot_config/i3/executable_i3blocks.conf @@ -0,0 +1,155 @@ +# i3blocks config file + +# source is available here: +# https://raw.githubusercontent.com/endeavouros-team/i3-EndeavourOS/master/.config/i3/i3blocks.conf +# Maintainer: joekamprad [joekamprad@endeavouros.com] +# created for i3wm setup on EndeavourOS +# https://endeavouros.com + +# cheatsheet for icon fonts used on the block-bar: +# https://fontawesome.com/cheatsheet + +# Please see man i3blocks for a complete reference! +# The man page is also hosted at http://vivien.github.io/i3blocks + + +# List of valid properties: +# +# align +# color +# command +# full_text +# instance +# interval +# label +# min_width +# name +# separator +# separator_block_width +# short_text +# signal +# urgent + +# Global properties +# +# The top properties below are applied to every block, but can be overridden. +separator=false +markup=pango + +#[apps] +#full_text=Applications: +#separator=true + +#[terminal] +#full_text=Terminal  +#color=#807dfe +#command=xfce4-terminal +#separator=true +# +#[browser] +#full_text=Browser  +#color=#ff7f81 +#command=firefox +#separator=true +# +#[files] +#full_text=Files  +#color=#7f3fbf +#command=thunar ~/ +#separator=true + +#[mail] +#full_text=Mail  +#color=#dbcb75 +#command=thunderbird +#separator=true + +#[bandwidth] +#command=~/.config/i3/scripts/bandwidth2 +#color=#e07221 +#interval=persist + +# [net] +# label=SSID: +# command=echo "$(LANG=C nmcli d | grep connected | awk '{print $4}')" +# color=#e07221 +# interval=5 +# separator=true + +# Players online on Karaoke server +[karaoke] +label=M +command=mcstatus rustybever.be status | grep -o '[0-9]*/[0-9]*' +color=#96c6f8 +interval=60 + +# Memory usage +# +# The type defaults to "mem" if the instance is not specified. +[memory] +label= +command=~/.config/i3/scripts/memory +color=#96c6f8 +interval=30 + +# Disk usage +# +# The directory defaults to $HOME if the instance is not specified. +# The script may be called with a optional argument to set the alert +# (defaults to 10 for 10%). +[disk] +label=~ +instance=/home +command=~/.config/i3/scripts/disk +color=#96c6f8 +interval=30 + +[disk] +label= +instance=/ +command=~/.config/i3/scripts/disk +color=#96c6f8 +interval=30 + +[CPU-temperature] +label=CPU +command=~/.config/i3/scripts/temperature --chip coretemp-isa-0000 +color=#96c6f8 +interval=5 + +[cpu_usage] +label= +interval=5 +command=~/.config/i3/scripts/cpu_usage +color=#96c6f8 +#min_width=CPU: 100.00% + +# Battery indicator +# +# The battery instance defaults to 0. +[battery] +command=~/.config/i3/scripts/battery.sh +label= +#instance=1 +interval=30 + +# Volume indicator +[volume-pulseaudio] +label=Vol: +command=~/.config/i3/scripts/volume +color=#208273 +instance=Master +interval=1 + +[time] +label= +command=date '+%a %d %b %Y %H:%M:%S' +color=#dbcb75 +interval=1 + +#[shutdown_menu] +#full_text= +#command=~/.config/i3/scripts/shutdown_menu -p rofi -c; +#color=#96c6f8 + + diff --git a/dot_config/i3/executable_startup.sh b/dot_config/i3/executable_startup.sh new file mode 100644 index 0000000..3079081 --- /dev/null +++ b/dot_config/i3/executable_startup.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env sh + +# Setup displays layout +autorandr --change + +# Display wallpapers +nitrogen --restore + +# Increase key repeat speed +xset r rate 150 30 + +# cur_layout="$(autorandr --current)" + +# # Properly set DPI & keyboard layout +# if [ "$cur_layout" = loftie ]; then +# xrandr --dpi 120 +# setxkbmap -layout us -variant altgr-intl + +# # Display sys tray on correct display +# elif [ "$cur_layout" = default ]; then +# xrandr --output eDP-1-1 --primary +# fi diff --git a/dot_config/i3/executable_swap_mod.sh b/dot_config/i3/executable_swap_mod.sh new file mode 100644 index 0000000..f1a7ec7 --- /dev/null +++ b/dot_config/i3/executable_swap_mod.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +CONF="${HOME}/.config/i3/config" + +if grep -q '$mod Mod4' "${CONF}"; then + sed -i 's/$mod Mod4/$mod Mod1/' "${CONF}" +else + sed -i 's/$mod Mod1/$mod Mod4/' "${CONF}" +fi diff --git a/dot_config/i3/i3status-rust.toml b/dot_config/i3/i3status-rust.toml new file mode 100644 index 0000000..ffc23fd --- /dev/null +++ b/dot_config/i3/i3status-rust.toml @@ -0,0 +1,62 @@ +[theme] +theme = "plain" + +[icons] +icons = "awesome5" + +[[block]] +block = "disk_space" +path = "/" +# format = "/" +info_type = "available" +# unit = "GB" +interval = 20 +warning = 20.0 +alert = 10.0 + +[[block]] +block = "disk_space" +path = "/home" +# format = "/home" +info_type = "available" +# unit = "GB" +interval = 20 +warning = 20.0 +alert = 10.0 + +[[block]] +block = "memory" +# display_type = "memory" +format = "$mem_used_percents $swap_used_percents" +# format_swap = "{swap_used_percents}" + +[[block]] +block = "cpu" +interval = 1 +format = "$utilization $frequency" + +[[block]] +block = "temperature" +# collapsed = false +interval = 1 +chip = "*-isa-*" + +# [[block]] +# block = "nvidia_gpu" +# label = "GTX 1060" +# show_memory = false +# show_clocks = true +# interval = 1 +# if_command = "command -v nvidia-smi" + +[[block]] +block = "sound" + +[[block]] +block = "battery" +format = "$percentage $time" + +[[block]] +block = "time" +interval = 1 +# format = "%a %d/%m %R" diff --git a/dot_config/i3/scripts/executable_bandwidth2 b/dot_config/i3/scripts/executable_bandwidth2 new file mode 100644 index 0000000..d21aefa --- /dev/null +++ b/dot_config/i3/scripts/executable_bandwidth2 @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2015 James Murphy +# Licensed under the terms of the GNU GPL v2 only. +# +# i3blocks blocklet script to monitor bandwidth usage + +iface="${BLOCK_INSTANCE}" +iface="${IFACE:-$iface}" +dt="${DT:-3}" +unit="${UNIT:-Mb}" +LABEL="${LABEL:-}" # down arrow up arrow +printf_command="${PRINTF_COMMAND:-"printf \"${LABEL}%-5.1f/%5.1f %s/s\\n\", rx, wx, unit;"}" + +function default_interface { + ip route | awk '/^default via/ {print $5; exit}' +} + +function check_proc_net_dev { + if [ ! -f "/proc/net/dev" ]; then + echo "/proc/net/dev not found" + exit 1 + fi +} + +function list_interfaces { + check_proc_net_dev + echo "Interfaces in /proc/net/dev:" + grep -o "^[^:]\\+:" /proc/net/dev | tr -d " :" +} + +while getopts i:t:u:p:lh opt; do + case "$opt" in + i) iface="$OPTARG" ;; + t) dt="$OPTARG" ;; + u) unit="$OPTARG" ;; + p) printf_command="$OPTARG" ;; + l) list_interfaces && exit 0 ;; + h) printf \ +"Usage: bandwidth3 [-i interface] [-t time] [-u unit] [-p printf_command] [-l] [-h] +Options: +-i\tNetwork interface to measure. Default determined using \`ip route\`. +-t\tTime interval in seconds between measurements. Default: 3 +-u\tUnits to measure bytes in. Default: Mb +\tAllowed units: Kb, KB, Mb, MB, Gb, GB, Tb, TB +\tUnits may have optional it/its/yte/ytes on the end, e.g. Mbits, KByte +-p\tAwk command to be called after a measurement is made. +\tDefault: printf \" %%-5.1f/%%5.1f %%s/s\\\\n\", rx, wx, unit; +\tExposed variables: rx, wx, tx, unit, iface +-l\tList available interfaces in /proc/net/dev +-h\tShow this help text +" && exit 0;; + esac +done + +check_proc_net_dev + +iface="${iface:-$(default_interface)}" +while [ -z "$iface" ]; do + echo No default interface + sleep "$dt" + iface=$(default_interface) +done + +case "$unit" in + Kb|Kbit|Kbits) bytes_per_unit=$((1024 / 8));; + KB|KByte|KBytes) bytes_per_unit=$((1024));; + Mb|Mbit|Mbits) bytes_per_unit=$((1024 * 1024 / 8));; + MB|MByte|MBytes) bytes_per_unit=$((1024 * 1024));; + Gb|Gbit|Gbits) bytes_per_unit=$((1024 * 1024 * 1024 / 8));; + GB|GByte|GBytes) bytes_per_unit=$((1024 * 1024 * 1024));; + Tb|Tbit|Tbits) bytes_per_unit=$((1024 * 1024 * 1024 * 1024 / 8));; + TB|TByte|TBytes) bytes_per_unit=$((1024 * 1024 * 1024 * 1024));; + *) echo Bad unit "$unit" && exit 1;; +esac + +scalar=$((bytes_per_unit * dt)) +init_line=$(cat /proc/net/dev | grep "^[ ]*$iface:") +if [ -z "$init_line" ]; then + echo Interface not found in /proc/net/dev: "$iface" + exit 1 +fi + +init_received=$(awk '{print $2}' <<< $init_line) +init_sent=$(awk '{print $10}' <<< $init_line) + +(while true; do cat /proc/net/dev; sleep "$dt"; done) |\ + stdbuf -oL grep "^[ ]*$iface:" |\ + awk -v scalar="$scalar" -v unit="$unit" -v iface="$iface" ' +BEGIN{old_received='"$init_received"';old_sent='"$init_sent"'} +{ + received=$2 + sent=$10 + rx=(received-old_received)/scalar; + wx=(sent-old_sent)/scalar; + tx=rx+wr; + old_received=received; + old_sent=sent; + if(rx >= 0 && wx >= 0){ + '"$printf_command"'; + fflush(stdout); + } +} +' diff --git a/dot_config/i3/scripts/executable_battery-pinebook-pro.sh b/dot_config/i3/scripts/executable_battery-pinebook-pro.sh new file mode 100644 index 0000000..142b31f --- /dev/null +++ b/dot_config/i3/scripts/executable_battery-pinebook-pro.sh @@ -0,0 +1,18 @@ +#!/bin/bash +#simple Shellscript for i3blocks on Pinebook pro +#05012020 geri123@gmx.net Gerhard S. +#battery-symbols: on Manjaro you need the awesome-terminal-fonts package installed! +PERCENT=$(cat /sys/class/power_supply/cw2015-battery/capacity) +STATUS=$(cat /sys/class/power_supply/cw2015-battery/status) +case $(( + $PERCENT >= 0 && $PERCENT <= 20 ? 1 : + $PERCENT > 20 && $PERCENT <= 40 ? 2 : + $PERCENT > 40 && $PERCENT <= 60 ? 3 : + $PERCENT > 60 && $PERCENT <= 80 ? 4 : 5)) in +# + (1) echo $STATUS:"" :$PERCENT%;; + (2) echo $STATUS:"" :$PERCENT%;; + (3) echo $STATUS:"" :$PERCENT%;; + (4) echo $STATUS:"" :$PERCENT%;; + (5) echo $STATUS:"" :$PERCENT%;; +esac diff --git a/dot_config/i3/scripts/executable_battery.sh b/dot_config/i3/scripts/executable_battery.sh new file mode 100644 index 0000000..d36acae --- /dev/null +++ b/dot_config/i3/scripts/executable_battery.sh @@ -0,0 +1,89 @@ +#!/usr/bin/perl +# +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# +# Licensed under the terms of the GNU GPL v3, or any later version. +# +# This script is meant to use with i3blocks. It parses the output of the "acpi" +# command (often provided by a package of the same name) to read the status of +# the battery, and eventually its remaining time (to full charge or discharge). +# +# The color will gradually change for a percentage below 85%, and the urgency +# (exit code 33) is set if there is less that 5% remaining. + +use strict; +use warnings; +use utf8; + +my $acpi; +my $status; +my $percent; +my $ac_adapt; +my $full_text; +my $short_text; +my $bat_number = $ENV{BLOCK_INSTANCE} || 0; + +# read the first line of the "acpi" command output +open (ACPI, "acpi -b | grep 'Battery $bat_number' |") or die; +$acpi = ; +close(ACPI); + +# fail on unexpected output +if ($acpi !~ /: (\w+), (\d+)%/) { + die "$acpi\n"; +} + +$status = $1; +$percent = $2; +$full_text = "$percent%"; + +if ($status eq 'Discharging') { + $full_text .= ' DIS'; +} elsif ($status eq 'Charging') { + $full_text .= ' CHR'; +} elsif ($status eq 'Unknown') { + open (AC_ADAPTER, "acpi -a |") or die; + $ac_adapt = ; + close(AC_ADAPTER); + + if ($ac_adapt =~ /: ([\w-]+)/) { + $ac_adapt = $1; + + if ($ac_adapt eq 'on-line') { + $full_text .= ' CHR'; + } elsif ($ac_adapt eq 'off-line') { + $full_text .= ' DIS'; + } + } +} + +$short_text = $full_text; + +if ($acpi =~ /(\d\d:\d\d):/) { + $full_text .= " ($1)"; +} + +# print text +print "$full_text\n"; +print "$short_text\n"; + +# consider color and urgent flag only on discharge +if ($status eq 'Discharging') { + + if ($percent < 20) { + print "#FF0000\n"; + } elsif ($percent < 40) { + print "#FFAE00\n"; + } elsif ($percent < 60) { + print "#FFF600\n"; + } elsif ($percent < 85) { + print "#A8FF00\n"; + } + + if ($percent < 5) { + exit(33); + } +} + +exit(0); diff --git a/dot_config/i3/scripts/executable_cpu_usage b/dot_config/i3/scripts/executable_cpu_usage new file mode 100644 index 0000000..44c1189 --- /dev/null +++ b/dot_config/i3/scripts/executable_cpu_usage @@ -0,0 +1,62 @@ +#!/usr/bin/perl +# +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# Copyright 2014 Andreas Guldstrand +# +# Licensed under the terms of the GNU GPL v3, or any later version. + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +# default values +my $t_warn = $ENV{T_WARN} // 50; +my $t_crit = $ENV{T_CRIT} // 80; +my $cpu_usage = -1; +my $decimals = $ENV{DECIMALS} // 2; +my $label = $ENV{LABEL} // ""; + +sub help { + print "Usage: cpu_usage [-w ] [-c ] [-d ]\n"; + print "-w : warning threshold to become yellow\n"; + print "-c : critical threshold to become red\n"; + print "-d : Use decimals for percentage (default is $decimals) \n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit, + "d=i" => \$decimals, +); + +# 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; +while () { + if (/^.*\s+(\d+\.\d+)[\s\x00]?$/) { + $cpu_usage = 100 - $1; # 100% - %idle + last; + } +} +close(MPSTAT); + +$cpu_usage eq -1 and die 'Can\'t find CPU information'; + +# Print short_text, full_text +print "${label}"; +printf "%.${decimals}f%%\n", $cpu_usage; +print "${label}"; +printf "%.${decimals}f%%\n", $cpu_usage; + +# Print color, if needed +if ($cpu_usage >= $t_crit) { + print "#FF0000\n"; + exit 33; +} elsif ($cpu_usage >= $t_warn) { + print "#FFFC00\n"; +} + +exit 0; diff --git a/dot_config/i3/scripts/executable_disk b/dot_config/i3/scripts/executable_disk new file mode 100644 index 0000000..c34240d --- /dev/null +++ b/dot_config/i3/scripts/executable_disk @@ -0,0 +1,48 @@ +#!/bin/sh +# Copyright (C) 2014 Julien Bonjean + +# 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 . + +DIR="${DIR:-$BLOCK_INSTANCE}" +DIR="${DIR:-$HOME}" +ALERT_LOW="${ALERT_LOW:-$1}" +ALERT_LOW="${ALERT_LOW:-10}" # color will turn red under this value (default: 10%) + +LOCAL_FLAG="-l" +if [ "$1" = "-n" ] || [ "$2" = "-n" ]; then + LOCAL_FLAG="" +fi + +df -h -P $LOCAL_FLAG "$DIR" | awk -v label="$LABEL" -v alert_low=$ALERT_LOW ' +/\/.*/ { + # full text + print label $4 + + # short text + print label $4 + + use=$5 + + # no need to continue parsing + exit 0 +} + +END { + gsub(/%$/,"",use) + if (100 - use < alert_low) { + # color + print "#FF0000" + } +} +' diff --git a/dot_config/i3/scripts/executable_exit_menu b/dot_config/i3/scripts/executable_exit_menu new file mode 100644 index 0000000..35b3231 --- /dev/null +++ b/dot_config/i3/scripts/executable_exit_menu @@ -0,0 +1,7 @@ +#!/bin/bash +while [ "$select" != "NO" -a "$select" != "YES" ]; do + select=$(echo -e 'NO\nYES' | dmenu -nb '#2f343f' -nf '#f3f4f5' -sb '#9575cd' -sf '#f3f4f5' -fn '-*-*-medium-r-normal-*-*-*-*-*-*-100-*-*' -i -p "Are you sure you want to logout?") + [ -z "$select" ] && exit 0 +done +[ "$select" = "NO" ] && exit 0 +i3-msg exit diff --git a/dot_config/i3/scripts/executable_literal_empty_workspace.sh b/dot_config/i3/scripts/executable_literal_empty_workspace.sh new file mode 100644 index 0000000..b4c28dc --- /dev/null +++ b/dot_config/i3/scripts/executable_literal_empty_workspace.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +MAX_DESKTOPS=20 + +WORKSPACES=$(seq -s '\n' 1 1 ${MAX_DESKTOPS}) + +EMPTY_WORKSPACE=$( (i3-msg -t get_workspaces | tr ',' '\n' | grep num | awk -F: '{print int($2)}' ; \ + echo -e ${WORKSPACES} ) | sort -n | uniq -u | head -n 1) + +i3-msg workspace ${EMPTY_WORKSPACE} diff --git a/dot_config/i3/scripts/executable_memory b/dot_config/i3/scripts/executable_memory new file mode 100644 index 0000000..90eb2c6 --- /dev/null +++ b/dot_config/i3/scripts/executable_memory @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright (C) 2014 Julien Bonjean + +# 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 . + +TYPE="${BLOCK_INSTANCE:-mem}" + +awk -v type=$TYPE ' +/^MemTotal:/ { + mem_total=$2 +} +/^MemFree:/ { + mem_free=$2 +} +/^Buffers:/ { + mem_free+=$2 +} +/^Cached:/ { + mem_free+=$2 +} +/^SwapTotal:/ { + swap_total=$2 +} +/^SwapFree:/ { + swap_free=$2 +} +END { + if (type == "swap") { + free=swap_free/1024/1024 + used=(swap_total-swap_free)/1024/1024 + total=swap_total/1024/1024 + } else { + free=mem_free/1024/1024 + used=(mem_total-mem_free)/1024/1024 + total=mem_total/1024/1024 + } + + pct=0 + if (total > 0) { + pct=used/total*100 + } + + # full text + printf("%.1fG/%.1fG (%.f%%)\n", used, total, pct) + + # short text + printf("%.f%%\n", pct) + + # color + if (pct > 90) { + print("#FF0000") + } else if (pct > 80) { + print("#FFAE00") + } else if (pct > 70) { + print("#FFF600") + } +} +' /proc/meminfo diff --git a/dot_config/i3/scripts/executable_openweather.conf b/dot_config/i3/scripts/executable_openweather.conf new file mode 100644 index 0000000..5d5d2e2 --- /dev/null +++ b/dot_config/i3/scripts/executable_openweather.conf @@ -0,0 +1,8 @@ +# Weather +[Weather] +command=~/.config/i3/scripts/openweather.sh +interval=1800 +color=#7275b3 + + + diff --git a/dot_config/i3/scripts/executable_openweather.sh b/dot_config/i3/scripts/executable_openweather.sh new file mode 100644 index 0000000..7fcef77 --- /dev/null +++ b/dot_config/i3/scripts/executable_openweather.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +command -v jq >/dev/null 2>&1 || { echo >&2 "Program 'jq' required but it is not installed. +Aborting."; exit 1; } +command -v wget >/dev/null 2>&1 || { echo >&2 "Program 'wget' required but is not installed. +Aborting."; exit 1; } + +APIKEY="get your key first" +#ZIPCODE="1234" +CITY_ID="Get your City ID first" +URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&units=metric&APPID=${APIKEY}" + +WEATHER_RESPONSE=$(wget -qO- "${URL}") + +WEATHER_CONDITION=$(echo $WEATHER_RESPONSE | jq '.weather[0].main' | sed 's/"//g') +WEATHER_TEMP=$(echo $WEATHER_RESPONSE | jq '.main.temp') +WIND_DIR=$( echo "$WEATHER_RESPONSE" | jq '.wind.deg') +WIND_SPEED=$( echo "$WEATHER_RESPONSE" | jq '.wind.speed') + +WIND_SPEED=$(awk "BEGIN {print 60*60*$WIND_SPEED/1000}") +WIND_DIR=$(awk "BEGIN {print int(($WIND_DIR % 360)/22.5)}") +DIR_ARRAY=( N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW N ) +WIND_DIR=${DIR_ARRAY[WIND_DIR]} + +case $WEATHER_CONDITION in + 'Clouds') + WEATHER_ICON="" + ;; + 'Rain') + WEATHER_ICON="" + ;; + 'Snow') + WEATHER_ICON="" + ;; + *) + WEATHER_ICON="" + ;; +esac + +echo "${WEATHER_ICON} ${WEATHER_TEMP}°C: ${WIND_SPEED} km/h ${WIND_DIR}" diff --git a/dot_config/i3/scripts/executable_shutdown_menu b/dot_config/i3/scripts/executable_shutdown_menu new file mode 100644 index 0000000..47ee609 --- /dev/null +++ b/dot_config/i3/scripts/executable_shutdown_menu @@ -0,0 +1,186 @@ +#!/usr/bin/env bash +# +# Use rofi/zenity to change system runstate thanks to systemd. +# +# Note: this currently relies on associative array support in the shell. +# +# Inspired from i3pystatus wiki: +# https://github.com/enkore/i3pystatus/wiki/Shutdown-Menu +# +# Copyright 2015 Benjamin Chrétien +# +# 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 . + +####################################################################### +# BEGIN CONFIG # +####################################################################### + +# Use a custom lock script +LOCKSCRIPT="light-locker-command -l" + +# Colors: FG (foreground), BG (background), HL (highlighted) +FG_COLOR="${FG_COLOR:-#bbbbbb}" +BG_COLOR="${BG_COLOR:-#111111}" +HLFG_COLOR="${HLFG_COLOR:-#111111}" +HLBG_COLOR="${HLBG_COLOR:-#bbbbbb}" +BORDER_COLOR="${BORDER_COLOR:-#222222}" + +# Options not related to colors +ROFI_TEXT="${ROFI_TEXT:-Menu:}" +ROFI_OPTIONS=(${ROFI_OPTIONS:--width 11 -location 3 -hide-scrollbar -bw 2}) + +# Zenity options +ZENITY_TITLE="${ZENITY_TITLE:-Menu}" +ZENITY_TEXT="${ZENITY_TEXT:-Action:}" +ZENITY_OPTIONS=(${ZENITY_OPTIONS:---column= --hide-header}) + +####################################################################### +# END CONFIG # +####################################################################### + +# Whether to ask for user's confirmation +enable_confirmation=${ENABLE_CONFIRMATIONS:-false} + +# Preferred launcher if both are available +preferred_launcher="${LAUNCHER:-rofi}" + +usage="$(basename "$0") [-h] [-c] [-p name] -- display a menu for shutdown, reboot, lock etc. + +where: + -h show this help text + -c ask for user confirmation + -p preferred launcher (rofi or zenity) + +This script depends on: + - systemd, + - i3, + - rofi or zenity." + +# Check whether the user-defined launcher is valid +launcher_list=(rofi zenity) +function check_launcher() { + if [[ ! "${launcher_list[@]}" =~ (^|[[:space:]])"$1"($|[[:space:]]) ]]; then + echo "Supported launchers: ${launcher_list[*]}" + exit 1 + else + # Get array with unique elements and preferred launcher first + # Note: uniq expects a sorted list, so we cannot use it + i=1 + launcher_list=($(for l in "$1" "${launcher_list[@]}"; do printf "%i %s\n" "$i" "$l"; let i+=1; done \ + | sort -uk2 | sort -nk1 | cut -d' ' -f2- | tr '\n' ' ')) + fi +} + +# Parse CLI arguments +while getopts "hcp:" option; do + case "${option}" in + h) echo "${usage}" + exit 0 + ;; + c) enable_confirmation=true + ;; + p) preferred_launcher="${OPTARG}" + check_launcher "${preferred_launcher}" + ;; + *) exit 1 + ;; + esac +done +check_launcher "${preferred_launcher}" + +# Check whether a command exists +function command_exists() { + command -v "$1" &> /dev/null 2>&1 +} + +# systemctl required +if ! command_exists systemctl ; then + exit 1 +fi + +# menu defined as an associative array +typeset -A menu + +# Menu with keys/commands +menu=( + [Shutdown]="systemctl poweroff" + [Reboot]="systemctl reboot" + [Hibernate]="systemctl hibernate" + [Suspend]="systemctl suspend" + [Halt]="systemctl halt" + [Lock]="${LOCKSCRIPT:-i3lock --color=${BG_COLOR#"#"}}" + [Logout]="i3-msg exit" + [Cancel]="" +) +menu_nrows=${#menu[@]} + +# Menu entries that may trigger a confirmation message +menu_confirm="Shutdown Reboot Hibernate Suspend Halt Logout" + +launcher_exe="" +launcher_options="" +rofi_colors="" + +function prepare_launcher() { + if [[ "$1" == "rofi" ]]; then + rofi_colors=(-bc "${BORDER_COLOR}" -bg "${BG_COLOR}" -fg "${FG_COLOR}" \ + -hlfg "${HLFG_COLOR}" -hlbg "${HLBG_COLOR}") + launcher_exe="rofi" + launcher_options=(-dmenu -i -lines "${menu_nrows}" -p "${ROFI_TEXT}" \ + "${rofi_colors[@]}" "${ROFI_OPTIONS[@]}") + elif [[ "$1" == "zenity" ]]; then + launcher_exe="zenity" + launcher_options=(--list --title="${ZENITY_TITLE}" --text="${ZENITY_TEXT}" \ + "${ZENITY_OPTIONS[@]}") + fi +} + +for l in "${launcher_list[@]}"; do + if command_exists "${l}" ; then + prepare_launcher "${l}" + break + fi +done + +# No launcher available +if [[ -z "${launcher_exe}" ]]; then + exit 1 +fi + +launcher=(${launcher_exe} "${launcher_options[@]}") +selection="$(printf '%s\n' "${!menu[@]}" | sort | "${launcher[@]}")" + +function ask_confirmation() { + if [ "${launcher_exe}" == "rofi" ]; then + confirmed=$(echo -e "Yes\nNo" | rofi -dmenu -i -lines 2 -p "${selection}?" \ + "${rofi_colors[@]}" "${ROFI_OPTIONS[@]}") + [ "${confirmed}" == "Yes" ] && confirmed=0 + elif [ "${launcher_exe}" == "zenity" ]; then + zenity --question --text "Are you sure you want to ${selection,,}?" + confirmed=$? + fi + + if [ "${confirmed}" == 0 ]; then + i3-msg -q "exec ${menu[${selection}]}" + fi +} + +if [[ $? -eq 0 && ! -z ${selection} ]]; then + if [[ "${enable_confirmation}" = true && \ + ${menu_confirm} =~ (^|[[:space:]])"${selection}"($|[[:space:]]) ]]; then + ask_confirmation + else + i3-msg -q "exec ${menu[${selection}]}" + fi +fi diff --git a/dot_config/i3/scripts/executable_temperature b/dot_config/i3/scripts/executable_temperature new file mode 100644 index 0000000..2170f10 --- /dev/null +++ b/dot_config/i3/scripts/executable_temperature @@ -0,0 +1,69 @@ +#!/usr/bin/env perl +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# Copyright 2014 Andreas Guldstrand +# Copyright 2014 Benjamin Chretien + +# 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 . + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +binmode(STDOUT, ":utf8"); + +# default values +my $t_warn = $ENV{T_WARN} || 70; +my $t_crit = $ENV{T_CRIT} || 90; +my $chip = $ENV{SENSOR_CHIP} || ""; +my $temperature = -9999; + +sub help { + print "Usage: temperature [-w ] [-c ] [--chip ]\n"; + print "-w : warning threshold to become yellow\n"; + print "-c : critical threshold to become red\n"; + print "--chip : sensor chip\n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit, + "chip=s" => \$chip); + +# Get chip temperature +open (SENSORS, "sensors -u $chip |") or die; +while () { + if (/^\s+temp1_input:\s+[\+]*([\-]*\d+\.\d)/) { + $temperature = $1; + last; + } +} +close(SENSORS); + +$temperature eq -9999 and die 'Cannot find temperature'; + +# Print short_text, full_text +print "$temperature°C\n" x2; + +# Print color, if needed +if ($temperature >= $t_crit) { + print "#FF0000\n"; + exit 33; +} elsif ($temperature >= $t_warn) { + print "#FFFC00\n"; +} + +exit 0; diff --git a/dot_config/i3/scripts/executable_volume b/dot_config/i3/scripts/executable_volume new file mode 100644 index 0000000..6e0c4fe --- /dev/null +++ b/dot_config/i3/scripts/executable_volume @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# Copyright (C) 2014 Julien Bonjean +# Copyright (C) 2014 Alexander Keller + +# 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 . + +#------------------------------------------------------------------------ + +# The second parameter overrides the mixer selection +# For PulseAudio users, eventually 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 +if [[ -z "$MIXER" ]] ; then + MIXER="default" + if command -v pulseaudio >/dev/null 2>&1 && pulseaudio --check ; then + # pulseaudio is running, but not all installations use "pulse" + if amixer -D pulse info >/dev/null 2>&1 ; then + MIXER="pulse" + fi + fi + [ -n "$(lsmod | grep jack)" ] && MIXER="jackplug" + MIXER="${2:-$MIXER}" +fi + +# 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` +if [[ -z "$SCONTROL" ]] ; then + SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols | + sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | + head -n1 + )}" +fi + +# 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) +if [[ -z "$STEP" ]] ; then + STEP="${1:-5%}" +fi + +#------------------------------------------------------------------------ + +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}' + output=$(perl -ne "$perl_filter") + echo "$LABEL$output" +} + +#------------------------------------------------------------------------ + +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/dot_config/picom.conf b/dot_config/picom.conf new file mode 100644 index 0000000..958eae0 --- /dev/null +++ b/dot_config/picom.conf @@ -0,0 +1,234 @@ +# Thank you code_nomad: http://9m.no/ꪯ鵞 +# and Arch Wiki contributors: https://wiki.archlinux.org/index.php/Compton + +################################# +# +# Backend +# +################################# + +# Backend to use: "xrender" or "glx". +# GLX backend is typically much faster but depends on a sane driver. +backend = "glx"; + +################################# +# +# GLX backend +# +################################# + +glx-no-stencil = true; + +# GLX backend: Copy unmodified regions from front buffer instead of redrawing them all. +# My tests with nvidia-drivers show a 10% decrease in performance when the whole screen is modified, +# but a 20% increase when only 1/4 is. +# My tests on nouveau show terrible slowdown. +glx-copy-from-front = false; + +# GLX backend: Use MESA_copy_sub_buffer to do partial screen update. +# My tests on nouveau shows a 200% performance boost when only 1/4 of the screen is updated. +# May break VSync and is not available on some drivers. +# Overrides --glx-copy-from-front. +# glx-use-copysubbuffermesa = true; + +# GLX backend: Avoid rebinding pixmap on window damage. +# Probably could improve performance on rapid window content changes, but is known to break things on some drivers (LLVMpipe). +# Recommended if it works. +# glx-no-rebind-pixmap = true; + +# GLX backend: GLX buffer swap method we assume. +# Could be undefined (0), copy (1), exchange (2), 3-6, or buffer-age (-1). +# undefined is the slowest and the safest, and the default value. +# copy is fastest, but may fail on some drivers, +# 2-6 are gradually slower but safer (6 is still faster than 0). +# Usually, double buffer means 2, triple buffer means 3. +# buffer-age means auto-detect using GLX_EXT_buffer_age, supported by some drivers. +# Useless with --glx-use-copysubbuffermesa. +# Partially breaks --resize-damage. +# Defaults to undefined. +#glx-swap-method = "undefined"; + +################################# +# +# Shadows +# +################################# + +# Enabled client-side shadows on windows. +shadow = true; +# The blur radius for shadows. (default 12) +shadow-radius = 5; +# The left offset for shadows. (default -15) +shadow-offset-x = -5; +# The top offset for shadows. (default -15) +shadow-offset-y = -5; +# The translucency for shadows. (default .75) +shadow-opacity = 0.5; + +# Set if you want different colour shadows +# shadow-red = 0.0; +# shadow-green = 0.0; +# shadow-blue = 0.0; + +# The shadow exclude options are helpful if you have shadows enabled. Due to the way picom draws its shadows, certain applications will have visual glitches +# (most applications are fine, only apps that do weird things with xshapes or argb are affected). +# This list includes all the affected apps I found in my testing. The "! name~=''" part excludes shadows on any "Unknown" windows, this prevents a visual glitch with the XFWM alt tab switcher. +shadow-exclude = [ + "! name~=''", + "name = 'Notification'", + "name = 'Plank'", + "name = 'Docky'", + "name = 'Kupfer'", + "name = 'xfce4-notifyd'", + "name *= 'VLC'", + "name *= 'compton'", + "name *= 'picom'", + "name *= 'Chromium'", + "name *= 'Chrome'", + "class_g = 'Firefox' && argb", + "class_g = 'Conky'", + "class_g = 'Kupfer'", + "class_g = 'Synapse'", + "class_g ?= 'Notify-osd'", + "class_g ?= 'Cairo-dock'", + "class_g ?= 'Xfce4-notifyd'", + "class_g ?= 'Xfce4-power-manager'", + "_GTK_FRAME_EXTENTS@:c", + "_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'" +]; +# Avoid drawing shadow on all shaped windows (see also: --detect-rounded-corners) +shadow-ignore-shaped = false; + +################################# +# +# Opacity +# +################################# + +inactive-opacity = 1; +active-opacity = 1; +frame-opacity = 1; +inactive-opacity-override = false; + +# Dim inactive windows. (0.0 - 1.0) +# inactive-dim = 0.2; +# Do not let dimness adjust based on window opacity. +# inactive-dim-fixed = true; +# Blur background of transparent windows. Bad performance with X Render backend. GLX backend is preferred. +blur-background = true; +# Blur background of opaque windows with transparent frames as well. +blur-background-frame = true; +# Do not let blur radius adjust based on window opacity. +blur-background-fixed = false; +blur-background-exclude = [ + "window_type = 'dock'", + "window_type = 'desktop'" +]; +blur: +{ + method = "dual_kawase"; + strength = 5; +} + +################################# +# +# Fading +# +################################# + +# Fade windows during opacity changes. +fading = true; +# The time between steps in a fade in milliseconds. (default 10). +fade-delta = 4; +# Opacity change between steps while fading in. (default 0.028). +fade-in-step = 0.03; +# Opacity change between steps while fading out. (default 0.03). +fade-out-step = 0.03; +# Fade windows in/out when opening/closing +# no-fading-openclose = true; + +# Specify a list of conditions of windows that should not be faded. +fade-exclude = [ ]; + +################################# +# +# Other +# +################################# + +# Try to detect WM windows and mark them as active. +mark-wmwin-focused = true; +# Mark all non-WM but override-redirect windows active (e.g. menus). +mark-ovredir-focused = true; +# Use EWMH _NET_WM_ACTIVE_WINDOW to determine which window is focused instead of using FocusIn/Out events. +# Usually more reliable but depends on a EWMH-compliant WM. +use-ewmh-active-win = true; +# Detect rounded corners and treat them as rectangular when --shadow-ignore-shaped is on. +detect-rounded-corners = true; + +# Detect _NET_WM_OPACITY on client windows, useful for window managers not passing _NET_WM_OPACITY of client windows to frame windows. +# This prevents opacity being ignored for some apps. +# For example without this enabled my xfce4-notifyd is 100% opacity no matter what. +detect-client-opacity = true; + +# Specify refresh rate of the screen. +# If not specified or 0, picom will try detecting this with X RandR extension. +refresh-rate = 0; + +# Vertical synchronization: match the refresh rate of the monitor +# Enable/disable VSync. +#vsync = true; +vsync = true; + +# Enable DBE painting mode, intended to use with VSync to (hopefully) eliminate tearing. +# Reported to have no effect, though. +dbe = false; + +# Limit picom to repaint at most once every 1 / refresh_rate second to boost performance. +# This should not be used with --vsync drm/opengl/opengl-oml as they essentially does --sw-opti's job already, +# unless you wish to specify a lower refresh rate than the actual value. +#sw-opti = true; + +# Unredirect all windows if a full-screen opaque window is detected, to maximize performance for full-screen windows, like games. +# Known to cause flickering when redirecting/unredirecting windows. +unredir-if-possible = false; + +# Specify a list of conditions of windows that should always be considered focused. +focus-exclude = [ ]; + +# Use WM_TRANSIENT_FOR to group windows, and consider windows in the same group focused at the same time. +detect-transient = true; +# Use WM_CLIENT_LEADER to group windows, and consider windows in the same group focused at the same time. +# WM_TRANSIENT_FOR has higher priority if --detect-transient is enabled, too. +detect-client-leader = true; + +################################# +# +# Window type settings +# +################################# + +wintypes: +{ + tooltip = + { + # fade: Fade the particular type of windows. + fade = true; + # shadow: Give those windows shadow + shadow = false; + # opacity: Default opacity for the type of windows. + opacity = 0.85; + # focus: Whether to always consider windows of this type focused. + focus = true; + }; +}; + +###################### +# +# XSync +# See: https://github.com/yshui/picom/commit/b18d46bcbdc35a3b5620d817dd46fbc76485c20d +# +###################### + +# Use X Sync fence to sync clients' draw calls. Needed on nvidia-drivers with GLX backend for some users. +xrender-sync-fence = true;