Skip to content

Instantly share code, notes, and snippets.

@jparrill
Created February 14, 2018 09:51
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jparrill/794544300af246e5cf24ad52ccd1296c to your computer and use it in GitHub Desktop.
Save jparrill/794544300af246e5cf24ad52ccd1296c to your computer and use it in GitHub Desktop.
i3 Config + Scripts
#!/bin/bash
import -window root /tmp/screenshot.png
convert /tmp/screenshot.png -spread 6 /tmp/screenshotblur.png
rm /tmp/screenshot.png
i3lock -i /tmp/screenshotblur.png
# Shadow
shadow = true;
no-dnd-shadow = true;
no-dock-shadow = true;
clear-shadow = true;
shadow-radius = 7;
shadow-offset-x = -7;
shadow-offset-y = -7;
# shadow-opacity = 0.7;
# shadow-red = 0.0;
# shadow-green = 0.0;
# shadow-blue = 0.0;
shadow-exclude = [
"name = 'Notification'",
"class_g = 'Conky'",
"class_g ?= 'Notify-osd'",
"class_g = 'Cairo-clock'",
"_GTK_FRAME_EXTENTS@:c"
];
# shadow-exclude = "n:e:Notification";
# shadow-exclude-reg = "x10+0+0";
# xinerama-shadow-crop = true;
# Opacity
menu-opacity = 0.8;
inactive-opacity = 0.8;
# active-opacity = 0.8;
frame-opacity = 0.7;
inactive-opacity-override = false;
alpha-step = 0.06;
# inactive-dim = 0.2;
# inactive-dim-fixed = true;
# blur-background = true;
# blur-background-frame = true;
blur-kern = "3x3box";
# blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1";
# blur-background-fixed = true;
blur-background-exclude = [
"window_type = 'dock'",
"window_type = 'desktop'",
"_GTK_FRAME_EXTENTS@:c"
];
# opacity-rule = [ "80:class_g = 'URxvt'" ];
opacity-rule = ["85:class_g = 'terminator'"];
opacity-rule = ["85:class_g = 'Terminator'"];
opacity-rule = ["85:class_g = 'Gnome-terminal'"];
# Fading
fading = true;
# fade-delta = 30;
fade-in-step = 0.03;
fade-out-step = 0.03;
# no-fading-openclose = true;
# no-fading-destroyed-argb = true;
fade-exclude = [ ];
# Other
backend = "xrender";
mark-wmwin-focused = true;
mark-ovredir-focused = true;
# use-ewmh-active-win = true;
detect-rounded-corners = true;
detect-client-opacity = true;
refresh-rate = 0;
vsync = "none";
dbe = false;
paint-on-overlay = true;
# sw-opti = true;
# unredir-if-possible = true;
# unredir-if-possible-delay = 5000;
# unredir-if-possible-exclude = [ ];
focus-exclude = [ "class_g = 'Cairo-clock'" ];
detect-transient = true;
detect-client-leader = true;
invert-color-include = [ ];
# resize-damage = 1;
# GLX backend
# glx-no-stencil = true;
glx-copy-from-front = false;
# glx-use-copysubbuffermesa = true;
# glx-no-rebind-pixmap = true;
glx-swap-method = "undefined";
# glx-use-gpushader4 = true;
# xrender-sync = true;
# xrender-sync-fence = true;
# Window type settings
wintypes:
{
tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; };
};
#!/usr/bin/python3
import requests
import random
CURRENCY = 'EUR'
SYMBOL = '€'
RANDOM = True
CRYPCOMPARE_API_URL = 'https://min-api.cryptocompare.com/data/price?fsym=%s&tsyms=%s'
#CRYPCOMPARE_CURRENCIES = ('BTC', 'ETH', 'LTC', 'XRP', 'LEND', 'POE', 'MANA', 'TRX')
CRYPCOMPARE_CURRENCIES = ('MANA', 'ETH')
if RANDOM:
CRYPCOMPARE_CURRENCIES = [ random.choice(CRYPCOMPARE_CURRENCIES) ]
values = {}
for currency in CRYPCOMPARE_CURRENCIES:
response = requests.get(
CRYPCOMPARE_API_URL % (currency, CURRENCY,))
json_value = response.json()
value = float(list(json_value.values())[0])
values[currency.lower()] = value
fmt = ' . '.join([
'%s: %.2f%s' % (currency, values[currency.lower()], SYMBOL)
for currency in CRYPCOMPARE_CURRENCIES
])
print(fmt)
# 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
set $script_path /home/jparrill/.config/i3/scripts
# 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
#font pango:Inconsolata 9
# 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 9
# 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
bindsym $mod+Return exec terminator
# kill focused window
bindsym $mod+Shift+q kill
# start dmenu (a program launcher)
#bindsym $mod+space exec dmenu_run
bindsym $mod+space exec rofi -show drun
# 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
#exec --no-startup-id compton -b -c -f --config ~/.config/i3/compton/compton.conf
# 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+ntilde 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
bindsym $mod+shift+p exec "$HOME/.config/i3/i3-pip toggle"
bindsym $mod+ctrl+p exec "$HOME/.config/i3/i3-pip move"
bindsym $mod+alt+p exec "$HOME/.config/i3/i3-pip size"
# change focus between tiling / floating windows
#bindsym $mod+shift+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# focus the child container
#bindsym $mod+d focus child
## Workspaces
set $web "2: "
set $term "3: "
set $code "4: "
set $music "6: "
set $chat "1: "
set $bj "5: "
set $backup "7: "
## Network
set $wifi ""
set $bt ""
## Battery
set $bat0 ""
set $bat1 ""
set $bat2 ""
set $bat3 ""
set $bat4 ""
# switch to workspace
bindsym $mod+1 workspace $chat
bindsym $mod+2 workspace $web
bindsym $mod+3 workspace $term;layout stacked
bindsym $mod+4 workspace $code
bindsym $mod+5 workspace $bj
bindsym $mod+6 workspace $music
bindsym $mod+7 workspace $backup
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9
bindsym $mod+0 workspace 0
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $chat
bindsym $mod+Shift+2 move container to workspace $web
bindsym $mod+Shift+3 move container to workspace $term
bindsym $mod+Shift+4 move container to workspace $code
bindsym $mod+Shift+5 move container to workspace $bj
bindsym $mod+Shift+6 move container to workspace $music
bindsym $mod+Shift+7 move container to workspace $backup
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 0
## Assignations
# Terms
assign [class="Terminator"] $term
assign [class="gnome-terminal"] $term
# Spotify
assign [id="0x2600001"] $music
# Chats
## All in one Messenger
assign [class="0x3000001"] $chat
assign [class="Rambox"] $chat
assign [class="Telegram"] $chat
assign [class="Hexchat"] $chat
assign [class="Keybase"] $chat
# Code
assign [class="*vim"] $code
assign [class="atom"] $code
# Web
assign [class="Google-chrome"] $web
assign [class="vivaldi"] $web
assign [class="vivaldi-stable"] $web
assign [class="firefox"] $web
# BJ
assign [class="bluejeans"] $bj
# Backup
assign [class="synology-cloud-station-backup"] $backup
# 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 10 px or 10 ppt
bindsym k resize grow height 10 px or 10 ppt
bindsym l resize shrink height 10 px or 10 ppt
bindsym ntilde 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
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"
# Custom
bindsym $mod+l exec $script_path/blurlock.sh
bindsym --release $mod+z exec "scrot -e 'mv $f ~/screenshots/%s_%H%M_%d%m%Y_$wx$h.png'"
bindsym --release $mod+Shift+z exec "scrot -se 'mv $f ~/screenshots/%s_%H%M_%d%m%Y_$wx$h.png'"
## Media keys
bindsym XF86AudioLowerVolume exec /usr/bin/pactl set-sink-volume @DEFAULT_SINK@ '-5%'
bindsym XF86AudioRaiseVolume exec /usr/bin/pactl set-sink-volume @DEFAULT_SINK@ '+5%'
bindsym XF86AudioMute exec /usr/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle
#bindsym XF86AudioRaiseVolume exec amixer -q set Master 4%+ unmute
#bindsym XF86AudioLowerVolume exec amixer -q set Master 4%- unmute
#bindsym XF86AudioMute exec amixer -D pulse set Master 1+ toggle
## Media player controls
# bindsym XF86AudioPlay exec playerctl play-pause
# bindsym XF86AudioPause exec playerctl pause
# bindsym XF86AudioNext exec playerctl next
# bindsym XF86AudioPrev exec playerctl previous
bindcode 74 exec playerctl play-pause
bindcode 75 exec playerctl next
bindcode 73 exec playerctl previous
## brightness control
bindsym XF86MonBrightnessDown exec xbacklight -steps 1 -time 0 -dec 5
bindsym XF86MonBrightnessUp exec xbacklight -steps 1 -time 0 -inc 10
bindsym $mod+67 exec xbacklight -steps 1 -time 0 -dec 5
bindsym $mod+68 exec xbacklight -steps 1 -time 0 -inc 10
# show battery stats
bindsym XF86Battery exec gnome-power-statistics
## Network
#exec_always --no-startup-id nm-applet
## Wall
exec --no-startup-id ~/.config/i3/wall/random_wallpaper.sh
#exec --no-startup-id ~/.fehbg
## Autostart
exec --no-startup-id owncloud
exec --no-startup-id hexchat
exec --no-startup-id rambox
exec --no-startup-id terminator
exec --no-startup-id google-chrome
exec --no-startup-id synology-cloud-station-backup
#exec --no-startup-id keybase
exec --no-startup-id xautolock -time 5 -locker "$script_path/blurlock.sh"
## Monitors
bindsym $mod+m move workspace to output right
## Notif
exec --no-startup-id dunst -config ~/.config/i3/dunst/dunstrc
# Windows without titlebars
for_window [class="^.*"] border pixel 2
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 $script_path/blurlock.sh, mode "default"
bindsym e exec --no-startup-id $script_path/i3exit logout, mode "default"
bindsym s exec --no-startup-id $script_path/i3exit suspend, mode "default"
bindsym h exec --no-startup-id $script_path/i3exit hibernate, mode "default"
bindsym r exec --no-startup-id $script_path/i3exit reboot, mode "default"
bindsym Shift+s exec --no-startup-id $script_path/i3exit shutdown, mode "default"
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+y mode "$mode_system"
set $environments Environments (p)roduban (b)bva (h)ome
mode "$environments" {
bindsym p exec i3exit lock, mode "default"
# bindsym Return mode "default"
bindsym Escape mode "default"
}
#bindsym $mod+e mode "$environments"
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
status_command py3status -c ~/.config/i3/status_bar/i3status.conf --include ~/.config/i3/py3_custom_modules
position top
}
# i3status configuration file.
# see "man i3status" for documentation.
general {
# These will be used if not supplied by a module
color = '#FFFFFF'
color_good = '#00FF00'
color_bad = '#FF0000'
color_degraded = '#FFFF00'
}
battery_level {
charging_character = ''
notification_low_level = True
blocks = ""
color_good = '#00AA00'
color_bad = '#AA0000'
color_degraded = '#AAAA00'
color_charging = '#FFFF00'
}
click_info {}
#order += "click_info"
order += "window_title"
order += "spotify"
order += "external_script cryptocurrency"
order += "external_script stock"
order += "pomodoro"
order += "group disks"
order += "wireless wlp4s0"
order += "ethernet enp0s31f6"
order += "ethernet tun0"
#order += "vpn_status RH-AMS"
order += "battery_level"
order += "do_not_disturb"
order += "online_status"
order += "volume_status"
order += "load"
order += "time"
window_title {}
wireless "wlp4s0" {
format_up = ":%ip"
format_down = ":"
}
ethernet "enp0s31f6" {
format_up = ":%ip"
format_down = ":"
}
ethernet "tun0" {
format_up = ":%ip"
format_down = ":"
}
online_status {
icon_off = ""
icon_on = ""
}
vpn_status "RH-AMS" {
format = ''
check_pid = True
pidfile = '/sys/devices/virtual/net/tun0/dev_id'
}
time {
format = "%Y-%m-%d %H:%M:%S"
color = '#FFF0F0'
}
do_not_disturb {
state_on = ''
state_off = ''
}
external_script "cryptocurrency" {
script_path = '~/.config/i3/scripts/crypto_cmp.py'
cache_timeout = 30
}
external_script "stock" {
script_path = '~/.config/i3/scripts/stock.py'
cache_timeout = 1200
}
load {format = "%1min"}
player_control {
stop_icon = ''
play_icon = ''
pause_icon = ''
}
spotify {
format = ': {title}'
format_down = ''
format_stopped = ''
on_click 1 = 'workspace 6: ; exec spotify'
on_click 3 = 'exec killall -r "spotify*"'
}
volume_status {
button_up = 4
button_down = 5
button_mute = 2
thresholds = [
(0, "#FF0000"),
(10, "#E2571E"),
(20, "#FF7F00"),
(30, "#FFFF00"),
(40, "#00FF00"),
(50, "#96BF33"),
(60, "#0000FF"),
(70, "#4B0082"),
(80, "#8B00FF"),
(90, "#FFFFFF")
]
}
group disks {
cycle = 30
format = ": {output} {button}"
disk "/" {
format = "/ %avail"
}
disk "/home" {
format = "/home %avail"
}
}
pomodoro {
display_bar = True
format = "{bar}"
timer_pomodoro = 2500
timer_break = 500
sound_pomodoro_end = "/usr/share/sounds/Oxygen-K3B-Finish-Success.ogg"
sound_pomodoro_start = "/usr/share/sounds/Oxygen-K3B-Finish-Error.ogg"
}
#!/bin/zsh
# dotfiles: collection of my personal dotfiles [code]
# Copyright (C) 2012-2016 Aleksa Sarai <cyphar@cyphar.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/>.
# Output help page.
function _help() {
cat <<EOH
usage: lockmyi3 [-h] [-p <size=20>] [options]...
Locks your screen with i3lock, using a pixelated version of the current screen
as the background. The semantics of the "current screen" are borrowed from
ImageMagick's 'import -screen -window root' options.
Options:
-p <size=20> -- Set the the size of each blocky pixel to <size> (in pixels).
options -- Options that are passed through to i3lock.
EOH
}
# Helper to calculate simple expressions.
function _calc() {
bc -q <<<"$1"
}
# Get the options.
local __block_size=20
while getopts "p:h" __opt; do
case "$__opt" in
(p)
__block_size="${OPTARG}"
;;
(h)
_help
exit 0;;
esac
done
# Get pass-through options.
shift $(_calc "${OPTIND}-1")
# Gets the (width, height) of the screen.
read __screen_x __screen_y <<<$(xrandr -q | awk '
# xrandr tells us screen sizes.
$1 == "Screen" {
# Line is of the form:
# Screen 0: minimum 8 x 8, current 3840 x 1080, maximum 32767 x 32767
for(i = 1; i <= NF && $i != "current"; i++)
;
# We did not find "current".
if($i != "current")
exit 1;
# Output the dimensions (there may be a trailing comma).
print $(i+1), $(i+3);
exit;
}' | tr -d ,)
# Calculate the "reduced" height and width for the down-scaling.
local __reduced_x=$(_calc "${__screen_x}/${__block_size}")
local __reduced_y=$(_calc "${__screen_y}/${__block_size}")
# Actually do the locking (generate the image without temporary files to not
# clutter the filesystem). Since `convert -scale` doesn't do blurring, scaling
# down and then back up is an efficient method of producing a pixelated image.
i3lock $* -i \
<(import -screen -window root -silent png:- | \
convert png:- \
-scale '!'"${__reduced_x}x${__reduced_y}" \
-scale '!'"${__screen_x}x${__screen_y}" \
png:-)
#!/usr/bin/python
import urllib2
import json
def read_stock(symbol):
u = urllib2.urlopen("https://api.iextrading.com/1.0/stock/"+symbol+"/quote")
query = u.read()
a = json.loads(query)
return(a['symbol']+": "+str(a['iexRealtimePrice'])+"$")
def currency(currency_src,currency_dst = "usd"):
u = urllib2.urlopen("https://api.cryptonator.com/api/ticker/"+currency_src)
query = u.read()
a = json.loads(query)
return(a['ticker']['base']+"/"+a['ticker']['target']+": "+("%.6f" % float(a['ticker']['price'])))
#Stocks can be provided with just the symbol (AAPL) or exchange:symbol (NASDAQ:AAPL)
stocks={"RHT"}
currencies={"USD-EUR"}
line = []
for i in stocks:
line = line + [read_stock(i)]
#for i in currencies:
# line = line + [currency(i)]
print " \n".join(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment