Last active
January 19, 2018 10:22
-
-
Save poddarh/df74dfca953791cade959af704b96873 to your computer and use it in GitHub Desktop.
i3-config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# Copyright 2014 Pierre Mavro <deimos@deimos.fr> | |
# Copyright 2014 Vivien Didelot <vivien@didelot.org> | |
# | |
# 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 $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 = <ACPI>; | |
close(ACPI); | |
# fail on unexpected output | |
if ($acpi !~ /: (\w+), (\d+)%/) { | |
die "$acpi\n"; | |
} | |
$status = $1; | |
$percent = $2; | |
$full_text = ""; | |
if ($status eq 'Discharging') { | |
$full_text .= "⚡$percent% Bat"; | |
} elsif ($status eq 'Charging') { | |
$full_text .= "$percent% Chr"; | |
} | |
elsif ($status eq 'Unknown' || $status eq 'Full') { | |
$full_text .= "⚡$percent%"; | |
} | |
$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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 http://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:Source Sans Pro 10 | |
# 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 | |
# Before i3 v4.8, we used to recommend this one as the default: | |
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 | |
# The font above is very space-efficient, that is, it looks good, sharp and | |
# clear in small sizes. However, its unicode glyph coverage is limited, the old | |
# X core fonts rendering does not support right-to-left and this being a bitmap | |
# font, it doesn’t scale on retina/hidpi displays. | |
# Use Mouse+$mod to drag floating windows to their wanted position | |
floating_modifier $mod | |
# start a terminal | |
bindsym $mod+Return exec i3-sensible-terminal | |
# kill focused window | |
bindsym $mod+Shift+q kill | |
# start dmenu (a program launcher) | |
# bindsym $mod+d exec 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+d exec --no-startup-id i3-dmenu-desktop | |
# change focus | |
bindsym $mod+j focus left | |
bindsym $mod+k focus down | |
bindsym $mod+l focus up | |
bindsym $mod+semicolon 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+j move left | |
bindsym $mod+Shift+k move down | |
bindsym $mod+Shift+l move up | |
bindsym $mod+Shift+semicolon 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+h split h | |
# split in vertical orientation | |
bindsym $mod+v 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+space floating toggle | |
# change focus between tiling / floating windows | |
bindsym $mod+space focus mode_toggle | |
# focus the parent container | |
bindsym $mod+a focus parent | |
# focus the child container | |
#bindsym $mod+d focus child | |
# switch to workspace | |
bindsym $mod+1 workspace 1 | |
bindsym $mod+2 workspace 2 | |
bindsym $mod+3 workspace 3 | |
bindsym $mod+4 workspace 4 | |
bindsym $mod+5 workspace 5 | |
bindsym $mod+6 workspace 6 | |
bindsym $mod+7 workspace 7 | |
bindsym $mod+8 workspace 8 | |
bindsym $mod+9 workspace 9 | |
bindsym $mod+0 workspace 10 | |
bindsym $mod+grave workspace 10 | |
# move focused container to workspace | |
bindsym $mod+Shift+1 move container to workspace 1 | |
bindsym $mod+Shift+2 move container to workspace 2 | |
bindsym $mod+Shift+3 move container to workspace 3 | |
bindsym $mod+Shift+4 move container to workspace 4 | |
bindsym $mod+Shift+5 move container to workspace 5 | |
bindsym $mod+Shift+6 move container to workspace 6 | |
bindsym $mod+Shift+7 move container to workspace 7 | |
bindsym $mod+Shift+8 move container to workspace 8 | |
bindsym $mod+Shift+9 move container to workspace 9 | |
bindsym $mod+Shift+0 move container to workspace 10 | |
bindsym $mod+Shift+grave move container to workspace 10 | |
# 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'" | |
# 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 j resize shrink width 25 px or 10 ppt | |
bindsym k resize grow height 25 px or 10 ppt | |
bindsym l resize shrink height 25 px or 10 ppt | |
bindsym semicolon resize grow width 25 px or 10 ppt | |
# same bindings, but for the arrow keys | |
bindsym Left resize shrink width 25 px or 10 ppt | |
bindsym Down resize grow height 25 px or 10 ppt | |
bindsym Up resize shrink height 25 px or 10 ppt | |
bindsym Right resize grow width 25 px or 10 ppt | |
# Shift bindings for smaller changes | |
bindsym Shift+j resize shrink width 5 px or 5 ppt | |
bindsym Shift+k resize grow height 5 px or 5 ppt | |
bindsym Shift+l resize shrink height 5 px or 5 ppt | |
bindsym Shift+semicolon resize grow width 5 px or 5 ppt | |
# same bindings, but for the arrow keys | |
bindsym Shift+Left resize shrink width 5 px or 5 ppt | |
bindsym Shift+Down resize grow height 5 px or 5 ppt | |
bindsym Shift+Up resize shrink height 5 px or 5 ppt | |
bindsym Shift+Right resize grow width 5 px or 5 ppt | |
# back to normal: Enter or Escape | |
bindsym Return mode "default" | |
bindsym Escape mode "default" | |
} | |
bindsym $mod+r mode "resize" | |
# Force certain windows to float | |
for_window [window_role="pop-up"] floating enable | |
for_window [title="Volume Control"] floating enable | |
for_window [title="Bluetooth Devices"] floating enable | |
for_window [title="Screen Layout Editor"] floating enable | |
for_window [title="Facebook Call - Google Chrome"] floating enable sticky enable | |
for_window [class="Nautilus"] floating enable | |
# Start i3bar to display a workspace bar (plus the system information i3status | |
# finds out, if available) | |
bar { | |
tray_output primary | |
font pango:SauceCodePro Nerd Font 11 | |
status_command i3blocks -c ~/.config/i3/i3blocks.conf | |
colors { | |
separator #268bd2 | |
background #002b36 | |
statusline #839496 | |
focused_workspace #fdf6e3 #6c71c4 #fdf6e3 | |
active_workspace #fdf6e3 #6c71c4 #fdf6e3 | |
inactive_workspace #002b36 #586e75 #002b36 | |
urgent_workspace #d33682 #d33682 #fdf6e3 | |
} | |
} | |
client.focused #6c71c4 #6c71c4 #fdf6e3 #6c71c4 | |
client.focused_inactive #073642 #073642 #eee8d5 #6c71c4 | |
client.unfocused #073642 #073642 #93a1a1 #586e75 | |
client.urgent #d33682 #d33682 #fdf6e3 #dc322f | |
# Power Options | |
set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown | |
mode "$mode_system" { | |
bindsym l exec --no-startup-id ~/.config/i3/i3exit lock, mode "default" | |
bindsym e exec --no-startup-id ~/.config/i3/i3exit logout, mode "default" | |
bindsym s exec --no-startup-id ~/.config/i3/i3exit suspend, mode "default" | |
bindsym h exec --no-startup-id ~/.config/i3/i3exit hibernate, mode "default" | |
bindsym r exec --no-startup-id ~/.config/i3/i3exit reboot, mode "default" | |
bindsym Shift+s exec --no-startup-id ~/.config/i3/i3exit shutdown, mode "default" | |
# back to normal: Enter or Escape | |
bindsym Return mode "default" | |
bindsym Escape mode "default" | |
} | |
bindsym $mod+Escape mode "$mode_system" | |
# Move entire workspace to left | |
bindsym $mod+m move workspace to output left | |
bindsym $mod+Shift+m move workspace to output right | |
# Startup commands | |
exec --no-startup-id unity-settings-daemon | |
exec --no-startup-id nitrogen --restore | |
exec --no-startup-id nm-applet | |
exec --no-startup-id pasystray | |
exec --no-startup-id xfce4-volumed | |
exec --no-startup-id dropbox start | |
exec --no-startup-id blueman-applet | |
# Rofi Combi Launcher to choose from window switcher, applications and SSH Connections | |
bindsym $mod+d exec --no-startup-id "rofi -combi-modi window,drun,ssh -show combi -modi combi" | |
# Key Combination to toggle between stickiness of the current floating window (to remain on top of any workspace) | |
bindsym $mod+Shift+s sticky toggle | |
# Screenshot shortcuts | |
bindsym Print exec gnome-screenshot | |
bindsym $mod+Print exec gnome-screenshot --window | |
bindsym Control+Print exec gnome-screenshot --clipboard | |
bindsym $mod+Control+Print exec gnome-screenshot --window --clipboard | |
bindsym --release Shift+Print exec scrot -se 'mv "$f" ~/Pictures' 'Screenshot from %Y-%m-%d %H-%M-%S.png' | |
bindsym --release Control+Shift+Print exec scrot -se 'xclip -selection clipboard -t image/png -i $f && rm $f' | |
# Screen brightness controls | |
bindsym XF86MonBrightnessUp exec xbacklight -inc 10 # increase screen brightness | |
bindsym XF86MonBrightnessDown exec xbacklight -dec 10 # decrease screen brightness | |
# Pulse Audio controls | |
bindsym XF86AudioRaiseVolume exec amixer -q -D pulse sset Master 5%+ && pkill -RTMIN+10 i3blocks | |
bindsym XF86AudioLowerVolume exec amixer -q -D pulse sset Master 5%- && pkill -RTMIN+10 i3blocks | |
bindsym XF86AudioMute exec amixer -q -D pulse sset Master toggle && pkill -RTMIN+10 i3blocks | |
# Media player controls | |
bindsym XF86AudioPlay exec playerctl play-pause | |
bindsym XF86AudioPause exec playerctl play-pause | |
bindsym XF86AudioNext exec playerctl next | |
bindsym XF86AudioPrev exec playerctl previous | |
# Media keys for ThinkPad T460p ( Fn + [F10|F11|F12] ) | |
bindsym XF86Search exec playerctl play-pause | |
bindsym XF86Explorer exec playerctl next | |
bindsym XF86LaunchA exec playerctl previous | |
# Prevent mouse hover from changing the window in focus | |
focus_follows_mouse no | |
bindsym Mod1+Control+l exec --no-startup-id ~/.config/i3/i3exit lock | |
bindsym $mod+x exec --no-startup-id nautilus --no-desktop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
separator_block_width=14 | |
[mediaplayer] | |
command=~/.config/i3/mediaplayer | |
instance=spotify | |
interval=5 | |
signal=10 | |
#[memory] | |
#label=Mem: | |
#command=/usr/share/i3blocks/memory | |
#separator=false | |
#interval=30 | |
#[swap] | |
#label=Swap: | |
#command=/usr/share/i3blocks/memory swap | |
#interval=30 | |
[ist-time] | |
label= IST | |
command=TZ=Asia/Kolkata date '+%-l:%M %p' | |
interval=5 | |
color=#50C878 | |
[Weather] | |
command=~/.config/i3/IconicWeather.sh "01003" | iconv -c | |
interval=1800 | |
color=#e97ac8 | |
#[mail] | |
#label= | |
#command=~/.config/i3/.mail.sh.x | |
#interval=100 | |
#color=#7F00FF | |
[disk-root] | |
label= | |
command=/usr/share/i3blocks/disk / | |
interval=30 | |
color=#d33682 | |
[ssid] | |
label= | |
command=echo "$(iw dev wlp3s0 link | grep SSID | cut -d " " -f 2-)" | |
color=#1793D1 | |
interval=5 | |
[wireless] | |
label= | |
instance=wlp3s0 | |
command=/usr/share/i3blocks/iface | |
color=#00FF00 | |
interval=10 | |
[ethernet] | |
#label=E | |
#instance=enp0s31f6 | |
#command=/usr/share/i3blocks/network | |
#color=#00FF00 | |
#interval=10 | |
#[strength] | |
#command=echo "$(iw dev wlp3s0 link | grep signal | cut -d " " -f 2-)" | |
#interval=10 | |
#color=#cb4b16 | |
[temp] | |
label= | |
command=echo "$(sensors coretemp-isa-0000 | awk '/Physical/ {print $4}')" | |
interval=10 | |
color=#b58900 | |
[cpu] | |
#label=CPU | |
#command=/usr/share/i3blocks/cpu_usage | |
#interval=10 | |
#min_width=CPU: 100.00% | |
#separator=false | |
[battery] | |
#label=BAT | |
#label=⚡ | |
#command=/usr/share/i3blocks/battery BAT0 | |
command=~/.config/i3/battery BAT0 | |
interval=30 | |
[load] | |
label= | |
command=/usr/share/i3blocks/load_average | |
interval=10 | |
color=#6c71c4 | |
[volume] | |
command=~/.config/i3/volume-pulseaudio -F3 | |
interval=5 | |
signal=10 | |
[date] | |
label= | |
command=~/.config/i3/simplecal | |
interval=5 | |
color=#FFFFFF | |
[time] | |
#command-date " %a %m-%d-%y %l:%M:%S %p" | |
label= | |
command=date '+%-l:%M:%S %p' | |
interval=1 | |
color=#50C878 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
lock() { | |
gnome-screensaver-command --lock | |
} | |
case "$1" in | |
lock) | |
lock | |
;; | |
logout) | |
i3-msg exit | |
;; | |
suspend) | |
lock && systemctl suspend | |
;; | |
hibernate) | |
lock && systemctl hibernate | |
;; | |
reboot) | |
systemctl reboot | |
;; | |
shutdown) | |
systemctl poweroff | |
;; | |
*) | |
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}" | |
exit 2 | |
esac | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
METRIC=1 #Should be 0 or 1; 0 for F, 1 for C | |
if [ -z $1 ]; then | |
echo | |
echo "USAGE: weather.sh <locationcode>" | |
echo | |
exit 0; | |
fi | |
curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1 | perl -ne 'use utf8; if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; my @values=split(":",$1); if( $values[0] eq "Sunny" || $values[0] eq "Mostly Sunny" || $values[0] eq "Partly Sunny" || $values[0] eq "Intermittent Clouds" || $values[0] eq "Hazy Sunshine" || $values[0] eq "Hazy Sunshine" || $values[0] eq "Hot") | |
{ | |
my $sun = ""; | |
binmode(STDOUT, ":utf8"); | |
print "$sun"; | |
} | |
if( $values[0] eq "Mostly Cloudy" || $values[0] eq "Cloudy" || $values[0] eq "Dreary (Overcast)" || $values[0] eq "Fog") | |
{ | |
my $cloud = ""; | |
binmode(STDOUT, ":utf8"); | |
print "$cloud"; | |
} | |
if( $values[0] eq "Showers" || $values[0] eq "Mostly Cloudy w/ Showers" || $values[0] eq "Partly Sunny w/ Showers" || $values[0] eq "T-Storms"|| $values[0] eq "Mostly Cloudy w/ T-Storms"|| $values[0] eq "Partly Sunny w/ T-Storms"|| $values[0] eq "Rain") | |
{ | |
my $rain = ""; | |
binmode(STDOUT, ":utf8"); | |
print "$rain"; | |
} | |
if( $values[0] eq "Windy") | |
{ | |
my $wind = ""; | |
binmode(STDOUT, ":utf8"); | |
print "$wind"; | |
} | |
if($values[0] eq "Flurries" || $values[0] eq "Mostly Cloudy w/ Flurries" || $values[0] eq "Partly Sunny w/ Flurries"|| $values[0] eq "Snow"|| $values[0] eq "Mostly Cloudy w/ Snow"|| $values[0] eq "Ice"|| $values[0] eq "Sleet"|| $values[0] eq "Freezing Rain"|| $values[0] eq "Rain and Snow"|| $values[0] eq "Cold") | |
{ | |
my $snow = ""; | |
binmode(STDOUT, ":utf8"); | |
print "$rain"; | |
} | |
if($values[0] eq "Clear" || $values[0] eq "Mostly Clear" || $values[0] eq "Partly Cloudy"|| $values[0] eq "Intermittent Clouds"|| $values[0] eq "Hazy Moonlight"|| $values[0] eq "Mostly Cloudy"|| $values[0] eq "Partly Cloudy w/ Showers"|| $values[0] eq "Mostly Cloudy w/ Showers"|| $values[0] eq "Partly Cloudy w/ T-Storms"|| $values[0] eq "Mostly Cloudy w/ Flurries" || $values[0] eq "Mostly Cloudy w/ Snow") | |
{ | |
my $night = ""; | |
binmode(STDOUT, ":utf8"); | |
print "$night"; | |
} | |
my $regex = qr/(\d*)(C|F)/p; | |
if ( $values[1] =~ /$regex/g ) { | |
print " $1°$2"; | |
} else { | |
print " $values[1]"; | |
}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Copyright (C) 2014 Tony Crisci <tony@dubstepdish.com> | |
# 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/>. | |
# Requires playerctl binary to be in your path (except cmus) | |
# See: https://github.com/acrisci/playerctl | |
# Set instance=NAME in the i3blocks configuration to specify a music player | |
# (playerctl will attempt to connect to org.mpris.MediaPlayer2.[NAME] on your | |
# DBus session). | |
use Time::HiRes qw(usleep); | |
use Env qw(BLOCK_INSTANCE); | |
use constant DELAY => 50; # Delay in ms to let network-based players (spotify) reflect new data. | |
use constant SPOTIFY_STR => 'spotify'; | |
my @metadata = (); | |
my $player_arg = ""; | |
if ($BLOCK_INSTANCE) { | |
$player_arg = "--player='$BLOCK_INSTANCE'"; | |
} | |
use constant { | |
ACTION_PLAY_PAUSE => "PLAY_PAUSE", | |
ACTION_NEXT => "NEXT", | |
ACTION_PREVIOUS => "PREVIOUS", | |
ACTION_VOLUME_UP => "VOLUME_UP", | |
ACTION_VOLUME_DOWN => "VOLUME_DOWN", | |
}; | |
use constant { | |
EVENT_LEFT_CLICK => 1, | |
EVENT_MIDDLE_CLICK => 2, | |
EVENT_RIGHT_CLICK => 3, | |
EVENT_SCROLL_UP => 4, | |
EVENT_SCROLL_DOWN => 5, | |
}; | |
sub buttons { | |
my $method = shift; | |
my $event = $ENV{'BLOCK_BUTTON'}; | |
my $action = -1; | |
if ($event == EVENT_LEFT_CLICK) { $action = ACTION_PLAY_PAUSE } | |
elsif ($event == EVENT_MIDDLE_CLICK) { $action = ACTION_PREVIOUS } | |
elsif ($event == EVENT_RIGHT_CLICK) { $action = ACTION_NEXT } | |
elsif ($event == EVENT_SCROLL_UP) { $action = ACTION_VOLUME_UP } | |
elsif ($event == EVENT_SCROLL_DOWN) { $action = ACTION_VOLUME_DOWN } | |
if($method eq 'mpd') { | |
if ($action eq ACTION_PREVIOUS) { | |
system("mpc prev"); | |
} elsif ($action eq ACTION_PLAY_PAUSE) { | |
system("mpc toggle"); | |
} elsif ($action eq ACTION_NEXT) { | |
system("mpc next"); | |
} elsif ($action eq ACTION_VOLUME_UP) { | |
system("mpc volume +10"); | |
} elsif ($action eq ACTION_VOLUME_DOWN) { | |
system("mpc volume -10"); | |
} | |
} elsif ($method eq 'cmus') { | |
if ($action eq ACTION_PREVIOUS) { | |
system("cmus-remote --prev"); | |
} elsif ($action eq ACTION_PLAY_PAUSE) { | |
system("cmus-remote --pause"); | |
} elsif ($action eq ACTION_NEXT) { | |
system("cmus-remote --next"); | |
} | |
} elsif ($method eq 'playerctl') { | |
if ($action eq ACTION_PREVIOUS) { | |
system("playerctl $player_arg previous"); | |
usleep(DELAY * 1000) if $BLOCK_INSTANCE eq SPOTIFY_STR; | |
} elsif ($action eq ACTION_PLAY_PAUSE) { | |
system("playerctl $player_arg play-pause"); | |
} elsif ($action eq ACTION_NEXT) { | |
system("playerctl $player_arg next"); | |
usleep(DELAY * 1000) if $BLOCK_INSTANCE eq SPOTIFY_STR; | |
} | |
} | |
} | |
sub cmus { | |
my @cmus = split /^/, qx(cmus-remote -Q); | |
if ($? == 0) { | |
foreach my $line (@cmus) { | |
my @data = split /\s/, $line; | |
if (shift @data eq 'tag') { | |
my $key = shift @data; | |
my $value = join ' ', @data; | |
@metadata[0] = $value if $key eq 'artist'; | |
@metadata[1] = $value if $key eq 'title'; | |
} | |
} | |
if (@metadata) { | |
buttons('cmus'); | |
# metadata found so we are done | |
print(join ' - ', @metadata); | |
exit 0; | |
} | |
} | |
} | |
sub mpd { | |
my $data = qx(mpc current); | |
if (not $data eq '') { | |
buttons("mpd"); | |
print($data); | |
exit 0; | |
} | |
} | |
sub playerctl { | |
buttons('playerctl'); | |
my $artist = qx(playerctl $player_arg metadata artist); | |
# exit status will be nonzero when playerctl cannot find your player | |
exit(0) if $? || $artist eq '(null)'; | |
push(@metadata, $artist) if $artist; | |
my $title = qx(playerctl $player_arg metadata title); | |
exit(0) if $? || $title eq '(null)'; | |
push(@metadata, $title) if $title; | |
print(join(" - ", @metadata)) if @metadata; | |
} | |
if ($player_arg eq '' or $player_arg =~ /mpd/) { | |
mpd; | |
} | |
if ($player_arg =~ /cmus/) { | |
cmus; | |
} | |
playerctl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Licensed under the terms of the GNU GENERAL PUBLIC LICENSE v2, or any later version. | |
# date pattern, more at 'man date' | |
DATE_PATTERN="%A, %d %B" | |
# command after clicking | |
CAL="${BLOCK_INSTANCE:-gsimplecal}" | |
if [ "${BLOCK_BUTTON}" == "1" ]; then | |
i3-msg -q exec $CAL | |
fi | |
date +"$DATE_PATTERN" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Displays the default device, volume, and mute status for i3blocks | |
AUDIO_HIGH_SYMBOL=' ' | |
AUDIO_MED_THRESH=50 | |
AUDIO_MED_SYMBOL=' ' | |
AUDIO_LOW_THRESH=0 | |
AUDIO_LOW_SYMBOL=' ' | |
AUDIO_MUTED_SYMBOL=' ' | |
AUDIO_INTERVAL=5 | |
DEFAULT_COLOR="#ffb6c1" | |
MUTED_COLOR="#ff0000" | |
LONG_FORMAT=0 | |
SHORT_FORMAT=2 | |
USE_PERCENT=1 | |
USE_ALSA_NAME=0 | |
USE_DESCRIPTION=0 | |
SUBSCRIBE=0 | |
while getopts F:Sf:padH:M:L:X:T:t:C:c:i:h opt; do | |
case "$opt" in | |
S) SUBSCRIBE=1 ;; | |
F) LONG_FORMAT="$OPTARG" ;; | |
f) SHORT_FORMAT="$OPTARG" ;; | |
p) USE_PERCENT=0 ;; | |
a) USE_ALSA_NAME=1 ;; | |
d) USE_DESCRIPTION=1 ;; | |
H) AUDIO_HIGH_SYMBOL="$OPTARG" ;; | |
M) AUDIO_MED_SYMBOL="$OPTARG" ;; | |
L) AUDIO_LOW_SYMBOL="$OPTARG" ;; | |
X) AUDIO_MUTED_SYMBOL="$OPTARG" ;; | |
T) AUDIO_MED_THRESH="$OPTARG" ;; | |
t) AUDIO_LOW_THRESH="$OPTARG" ;; | |
C) DEFAULT_COLOR="$OPTARG" ;; | |
c) MUTED_COLOR="$OPTARG" ;; | |
i) AUDIO_INTERVAL="$OPTARG" ;; | |
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] [-h] | |
Options: | |
-F, -f\tOutput format (-F long format, -f short format) to use, amonst: | |
\t0\t symb vol [index:name]\t (default long) | |
\t1\t symb vol [name] | |
\t2\t symb vol [index]\t (default short) | |
\t3\t symb vol | |
-S\tSubscribe to volume events (requires persistent block, always uses long format) | |
-p\tOmit the percent sign (%%) in volume | |
-a\tUse ALSA name if possible | |
-d\tUse device description instead of name if possible | |
-H\tSymbol to use when audio level is high. Default: '$AUDIO_HIGH_SYMBOL' | |
-M\tSymbol to use when audio level is medium. Default: '$AUDIO_MED_SYMBOL' | |
-L\tSymbol to use when audio level is low. Default: '$AUDIO_LOW_SYMBOL' | |
-X\tSymbol to use when audio is muted. Default: '$AUDIO_MUTED_SYMBOL' | |
-T\tThreshold for medium audio level. Default: $AUDIO_MED_THRESH | |
-t\tThreshold for low audio level. Default: $AUDIO_LOW_THRESH | |
-C\tColor for non-muted audio. Default: $DEFAULT_COLOR | |
-c\tColor for muted audio. Default: $MUTED_COLOR | |
-i\tInterval size of volume increase/decrease. Default: $AUDIO_INTERVAL | |
-h\tShow this help text | |
" && exit 0;; | |
esac | |
done | |
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) amixer -q -D pulse sset Master toggle ;; | |
2) set_default_playback_device_next -1 ;; | |
3) set_default_playback_device_next ;; | |
4) amixer -q -D pulse sset Master $AUDIO_INTERVAL%+ ;; | |
5) amixer -q -D pulse sset Master $AUDIO_INTERVAL%- ;; | |
esac | |
function print_format { | |
PERCENT="%" | |
[[ $USE_PERCENT == 0 ]] && PERCENT="" | |
case "$1" in | |
1) echo "$SYMBOL$VOL$PERCENT [$NAME]" ;; | |
2) echo "$SYMBOL$VOL$PERCENT [$INDEX]";; | |
3) echo "$SYMBOL$VOL$PERCENT" ;; | |
*) echo "$SYMBOL$VOL$PERCENT [$INDEX:$NAME]" ;; | |
esac | |
} | |
function print_block { | |
for name in INDEX NAME VOL MUTED; do | |
read $name | |
done < <(pacmd list-sinks | grep "index:\|name:\|volume: front\|muted:" | grep -A3 '*') | |
INDEX=$(echo "$INDEX" | grep -o '[0-9]\+') | |
VOL=$(echo "$VOL" | grep -o "[0-9]*%" | head -1 ) | |
VOL="${VOL%?}" | |
NAME=$(echo "$NAME" | sed \ | |
's/.*<.*\.\(.*\)>.*/\1/; t;'\ | |
's/.*<\(.*\)>.*/\1/; t;'\ | |
's/.*/unknown/') | |
if [[ $USE_ALSA_NAME == 1 ]] ; then | |
ALSA_NAME=$(pacmd list-sinks |\ | |
awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\ | |
grep "alsa.name\|alsa.mixer_name" |\ | |
head -n1 |\ | |
sed 's/.*= "\(.*\)".*/\1/') | |
NAME=${ALSA_NAME:-$NAME} | |
elif [[ $USE_DESCRIPTION == 1 ]] ; then | |
DESCRIPTION=$(pacmd list-sinks |\ | |
awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\ | |
grep "device.description" |\ | |
head -n1 |\ | |
sed 's/.*= "\(.*\)".*/\1/') | |
NAME=${DESCRIPTION:-$NAME} | |
fi | |
if [[ $MUTED =~ "no" ]] ; then | |
SYMBOL=$AUDIO_HIGH_SYMBOL | |
[[ $VOL -le $AUDIO_MED_THRESH ]] && SYMBOL=$AUDIO_MED_SYMBOL | |
[[ $VOL -le $AUDIO_LOW_THRESH ]] && SYMBOL=$AUDIO_LOW_SYMBOL | |
COLOR=$DEFAULT_COLOR | |
else | |
SYMBOL=$AUDIO_MUTED_SYMBOL | |
COLOR=$MUTED_COLOR | |
fi | |
if [[ $SUBSCRIBE == 1 ]] ; then | |
print_format "$LONG_FORMAT" | |
else | |
print_format "$LONG_FORMAT" | |
print_format "$SHORT_FORMAT" | |
echo "$COLOR" | |
fi | |
} | |
print_block | |
if [[ $SUBSCRIBE == 1 ]] ; then | |
while read -r EVENT; do | |
print_block | |
done < <(pactl subscribe | stdbuf -oL grep change) | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation Instructions
i3wm
repository by following instructions on the website to get the latest version.albert
.sudo apt install i3 xbacklight feh conky blueman arandr pasystray nitrogen xfce4-pulseaudio-plugin xfce4-volumed i3blocks lm-sensors xclip scrot gsimplecal alsa-utils
playerctl
(latest release)~/.config/i3/
SauceCodePro Nerd Font
gsettings set org.gnome.desktop.background show-desktop-icons false
to disable nautilus from displaying icons over i3 when the file manager is opened.xdg-settings set default-web-browser google-chrome.desktop
to set Google Chrome as default browser./usr/share/X11/xorg.conf.d/20-intel.conf
with the following content: