Browse Source

Added raw i3 config

master
chodak166 5 days ago
parent
commit
39234f7d7a
  1. 581
      .config/i3/config
  2. 77
      .config/i3/py3status.conf
  3. 13
      .config/i3/scripts/always-float
  4. 32
      .config/i3/scripts/autoapp
  5. 21
      .config/i3/scripts/backlight
  6. 102
      .config/i3/scripts/bandwidth
  7. 81
      .config/i3/scripts/dmenu-i3-window-jumper
  8. 33
      .config/i3/scripts/i3exit
  9. 34
      .config/i3/scripts/load_average
  10. 56
      .config/i3/scripts/redshift-adjust
  11. 30
      .config/i3/scripts/top
  12. 5693
      .config/i3/scripts/trans
  13. 12
      .config/i3/scripts/trans-xsel
  14. 30
      .config/i3/scripts/volctl
  15. 70
      .config/i3/scripts/volume_auto

581
.config/i3/config

@ -0,0 +1,581 @@
# Dependencies:
# i3 i3blocks i3lock dbus-x11 suckless-tools x11-xserver-utils feh terminator libnotify-bin dunst yad pcmanfm compton py3status python3-pkg-resources software-properties-common xserver-xorg-input-synaptics xsel osmo gawk qt5ct file-roller git clipit network-manager-gnome redshift screengrab micro gnome-themes-extra geany geany-plugins lxappearance
#################################################################
# /profiles/current/config.d/01-variables:
#------------------------------------------------
#
# variable definitions
#
#------------------------------------------------
# what will be yout mod key? Use Mod4 for "window" key, Mod1 for "alt"
set $mod Mod4
#set $mod Mod1
# helper scripts location
#################################################################
# /profiles/current/config.d/10-workspaces:
#------------------------------------------------
#
# workspace settings
#
#------------------------------------------------
# workspaces
set $workspace1 1: >_
set $workspace2 2: dev
set $workspace3 3: www
set $workspace4 4: files
set $workspace5 5: e-mail
set $workspace6 6: IM
set $workspace7 7: video
set $workspace8 8: workspace
set $workspace9 9: workspace
set $workspace10 10: Music
set $workspace11 V: VM
# switch to workspace
bindsym $mod+1 workspace $workspace1
bindsym $mod+2 workspace $workspace2
bindsym $mod+3 workspace $workspace3
bindsym $mod+4 workspace $workspace4
bindsym $mod+5 workspace $workspace5
bindsym $mod+6 workspace $workspace6
bindsym $mod+7 workspace $workspace7
bindsym $mod+8 workspace $workspace8
bindsym $mod+9 workspace $workspace9
bindsym $mod+0 workspace $workspace10
#bindsym $mod+Mod1+v workspace $workspace11
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $workspace1
bindsym $mod+Shift+2 move container to workspace $workspace2
bindsym $mod+Shift+3 move container to workspace $workspace3
bindsym $mod+Shift+4 move container to workspace $workspace4
bindsym $mod+Shift+5 move container to workspace $workspace5
bindsym $mod+Shift+6 move container to workspace $workspace6
bindsym $mod+Shift+7 move container to workspace $workspace7
bindsym $mod+Shift+8 move container to workspace $workspace8
bindsym $mod+Shift+9 move container to workspace $workspace9
bindsym $mod+Shift+0 move container to workspace $workspace10
# next/prev workspace
bindsym $mod+x workspace next
bindsym $mod+Shift+x move container to workspace next
bindsym $mod+z workspace prev
bindsym $mod+Shift+z move container to workspace prev
# moving workspace across monitors
bindsym $mod+Control+Left move workspace to output left
bindsym $mod+Control+Right move workspace to output right
#################################################################
# /profiles/current/config.d/11-outputs:
#------------------------------------------------
#
# video output management
#
#------------------------------------------------
# monitors - use "xrandr --listmonitors" to obtain your output names
set $leftOutput eDP
set $rightOutput HDMI-A-0
# setup monitors
exec --no-startup-id xrandr --output $rightOutput --primary
exec --no-startup-id xrandr --output $leftOutput --left-of $rightOutput
mode "outputs" {
# mod + shift + 1 to turn off left monitor, mod + 1 to turn it on
bindsym $mod+Shift+1 exec xrandr --output $leftOutput --off; mode "default"; restart
bindsym $mod+1 exec xrandr --output $leftOutput --auto --left-of $rightOutput;mode "default"; restart
# mod + shift + 2 to turn off right monitor, mod + 2 to turn it on
bindsym $mod+Shift+2 exec xrandr --output $rightOutput --off; mode "default", restart
bindsym $mod+2 exec xrandr --output $rightOutput --auto --right-of $leftOutput; mode "default"; restart
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+m mode "outputs"
#################################################################
# /profiles/current/config.d/13-wallpaper:
#------------------------------------------------
#
# wallpaper settings
#
#------------------------------------------------
# wallpapers (second for multihead)
set $wallpaper1 ~/.cofnig/i3/wallpaper.jpg
# set wallpapers
exec_always --no-startup-id sleep 2 && feh --bg-scale $wallpaper1 --bg-scale $wallpaper1
# apply xrandr settings
exec_always --no-startup-id sleep 2 && xrandr --output $leftOutput --left-of $rightOutput
#################################################################
# /profiles/current/config.d/20-keys-apps-core:
#------------------------------------------------
#
# application running bindings
#
#------------------------------------------------
# start a terminal
#bindsym $mod+Return exec i3-sensible-terminal
#bindsym $mod+Return exec terminator -p ratflow-terminator
bindsym $mod+Return exec kitty
# start dmenu (a program launcher)
#bindsym $mod+d exec dmenu_run
#bindsym Mod1+F2 exec dmenu_run
#let's replace dmenu by custom launcher:
bindsym $mod+d exec ulauncher
bindsym Mod1+F2 exec dmenu_run
# run app assigned to current workspace
bindsym $mod+Shift+a exec $scriptsDir/autoapp
#################################################################
# /profiles/current/config.d/20-keys-window-jumper:
#bindsym Mod1+Tab exec "$scriptsDir/dmenu-i3-window-jumper &"
bindsym $mod+Tab workspace back_and_forth
#################################################################
# /profiles/current/config.d/20-keys-wm:
#------------------------------------------------
#
# window management bindings
#
#------------------------------------------------
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# kill focused window
bindsym $mod+Shift+q kill
# 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
# nested split in horizontal orientation
bindsym $mod+h split h
# nested split in vertical orientation
bindsym $mod+v split v
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen
# 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 --whole-window $mod+button2 floating toggle
# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# 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 semicolon 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"
#################################################################
# /profiles/current/config.d/21-always-float:
bindsym $mod+Shift+f exec $scriptsDir/always-float
#################################################################
# /profiles/current/config.d/21-keys-apps:
#------------------------------------------------
#
# application running bindings
#
#------------------------------------------------
# calendar
bindsym $mod+c exec osmo -c
# screenshots (full, region, active)
bindsym Print exec screengrab --fullscreen
bindsym Shift+Print exec screengrab --region
bindsym Control+Print exec screengrab --active
# redshift
bindsym $mod+Control+Next exec $scriptsDir/redshift-adjust -100
bindsym $mod+Control+Prior exec $scriptsDir/redshift-adjust +100
bindsym $mod+Control+l exec redshift -x
# translation of selected text
bindsym $mod+t exec bash -c "$scriptsDir/trans-xsel en:pl &"
bindsym $mod+Shift+t exec bash -c "$scriptsDir/trans-xsel pl:en &"
#################################################################
# /profiles/current/config.d/21-keys-media:
#------------------------------------------------
#
# multimedia keys and audio/video players bindings
#
#------------------------------------------------
# Pulse Audio controls (debian), the VOLCTL_SINK_NUM selects sink starting from the most recent one connected
bindsym XF86AudioRaiseVolume exec --no-startup-id (VOLCTL_SINK_NUM=1 $scriptsDir/volctl up)
bindsym XF86AudioLowerVolume exec --no-startup-id (VOLCTL_SINK_NUM=1 $scriptsDir/volctl down)
bindsym XF86AudioMute exec --no-startup-id (VOLCTL_SINK_NUM=1 $scriptsDir/volctl toggle)
bindsym Shift+XF86AudioRaiseVolume exec --no-startup-id (VOLCTL_SINK_NUM=2 $scriptsDir/volctl up)
bindsym Shift+XF86AudioLowerVolume exec --no-startup-id (VOLCTL_SINK_NUM=2 $scriptsDir/volctl down)
bindsym Shift+XF86AudioMute exec --no-startup-id (VOLCTL_SINK_NUM=2 $scriptsDir/volctl toggle)
# Sreen brightness controls
#bindsym XF86MonBrightnessUp exec xbacklight -inc 20 # increase screen brightness
#bindsym XF86MonBrightnessDown exec xbacklight -dec 20 # decrease screen brightness
bindsym XF86MonBrightnessUp exec $scriptsDir/backlight up
bindsym XF86MonBrightnessDown exec $scriptsDir/backlight down
# Media player controls
#bindsym XF86AudioPlay exec playerctl play
#bindsym XF86AudioPause exec playerctl pause
#bindsym XF86AudioNext exec playerctl next
#bindsym XF86AudioPrev exec playerctl previous
# Clementine player controls
bindsym XF86AudioPlay exec clementine --play-pause
bindsym XF86AudioPause exec clementine --pause
bindsym XF86AudioNext exec clementine --next
bindsym XF86AudioPrev exec clementine --previous
# bindsym Shift+XF86AudioRaiseVolume exec clementine --volume-up
# bindsym Shift+XF86AudioLowerVolume exec clementine --volume-down
#################################################################
# /profiles/current/config.d/21-keys-projector:
#------------------------------------------------
#
# media player bindings
#
#------------------------------------------------
# Pulse Audio controls (debian)
bindsym $mod+p exec /home/chodak/.screenlayout/projector.sh
bindsym Shift+$mod+p exec /home/chodak/.screenlayout/edp.sh
#################################################################
# /profiles/current/config.d/21-keys-session:
#------------------------------------------------
#
# session/power management
#
#------------------------------------------------
# regenerate and reload i3 configuration file
bindsym $mod+Shift+c exec rfreload
# suspend
bindsym $mod+Escape exec systemctl suspend
# regenerate i3 configuration file and restart i3 (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r exec rfreload --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'"
# use i3exit script from https://github.com/giacomos/i3wm-config/blob/master/i3exit
set $exitScript ~/.config/i3/scripts/i3exit
mode "session_management" {
bindsym l exec --no-startup-id $exitScript lock, mode "default"
bindsym e exec --no-startup-id $exitScript logout, mode "default"
bindsym s exec --no-startup-id $exitScript suspend, mode "default"
bindsym h exec --no-startup-id $exitScript hibernate, mode "default"
bindsym r exec --no-startup-id $exitScript reboot, mode "default"
bindsym Shift+s exec --no-startup-id $exitScript shutdown, mode "default"
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+Pause mode "session_management"
#################################################################
# /profiles/current/config.d/21-new-workspace:
# create temporary workspace
bindsym $mod+n exec name=$(yad --entry --splash --title "Create workspace" --text "Name of temporary workspace:") && i3-msg workspace $name
#################################################################
# /profiles/current/config.d/30-theme:
#------------------------------------------------
#
# appearance
#
#------------------------------------------------
# font
set $fontName Source Sans Pro Semi-Bold
set $fontSize 10
set $barFontSize 9
# colors
set $clFocusedActiveBorder #252525
set $clFocusedActiveBackground #252525
set $clFocusedActiveText #D9D9D9
set $clFocusedInactiveBorder #101010
set $clFocusedinactiveBackground #101010
set $clFocusedInactiveText #606060
set $clUnfocusedBorder #101010
set $clUnfocusedBackground #000000
set $clUnfocusedText #606060
set $clUrgentBorder #F05000
set $clUrgentBackground #F05000
set $clUrgentText #F0F0F0
set $clIndicator #101010
# --------- fonts ---------
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango: $fontName $fontSize
#font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# 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
# --------- windows ---------
# Widow Colours
# border background text indicator
client.focused $clFocusedActiveBorder $clFocusedActiveBackground $clFocusedActiveText $clIndicator
client.focused_inactive $clFocusedInactiveBorder $clFocusedinactiveBackground $clFocusedInactiveText $clIndicator
client.unfocused $clUnfocusedBorder $clUnfocusedBackground $clUnfocusedText $clIndicator
client.urgent $clUrgentBorder $clUrgentBackground $clUrgentText $clIndicator
#################################################################
# /profiles/current/config.d/31-bar:
#------------------------------------------------
#
# i3 bar
#
#------------------------------------------------
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
position top
i3bar_command i3bar -t
status_command py3status -c ~/.config/i3/py3status.conf
font xft:$fontName, FontAwesome $barFontsize
tray_padding 0
#Use tray_output primary/none/<output name> to define where the tray should be (multiple tray_output can be used)
#Remember to set any of your displays to primary (i.e. using xrandr)
#tray_output primary
colors {
separator $clFocusedActiveText
#background $clUnfocusedBackground
background #00000070
#statusline #FFFFFF99
statusline $clFocusedActiveText
# border background text
focused_workspace $clFocusedActiveBackground $clFocusedActiveBackground $clFocusedActiveText
active_workspace $clFocusedActiveBorder $clFocusedActiveBackground $clFocusedActiveText
inactive_workspace $clUnfocusedBackground $clUnfocusedBackground $clUnfocusedText
urgent_workspace $clUrgentBorder $clUrgentBackground $clUrgentText
}
}
#################################################################
# /profiles/current/config.d/40-assignments:
#------------------------------------------------
#
# assign applications to workspaces
#
#------------------------------------------------
assign [class="Qtcreator"] $workspace2
assign [class="Eclipse"] $workspace2
#assign [class="Kate"] $workspace2
#assign [class="Gedit"] $workspace2
#assign [class="Emacs"] $workspace2
assign [class="Iceweasel"] $workspace3
assign [class="Firefox"] $workspace3
assign [class="Chromium-browser"] $workspace3
assign [class="Chrome"] $workspace3
assign [class="Pcmanfm"] $workspace4
assign [class="Dolphin"] $workspace4
assign [class="Nautilus"] $workspace4
assign [class="Thunar"] $workspace4
assign [class="Thunderbird"] $workspace5
assign [class="Kadu"] $workspace6
assign [class="Skype"] $workspace6
assign [class="Pidgin"] $workspace6
assign [class="Kopete"] $workspace6
assign [class="Telegram"] $workspace6
#assign [class="Smplayer"] $workspace7
#assign [class="Smplayer2"] $workspace7
#assign [class="Mplayer"] $workspace7
#assign [class="Vlc"] $workspace7
#assign [class="dragonplayer"] $workspace7
assign [class="Kodi"] $workspace7
assign [class="Clementine"] $workspace10
assign [class="Rhythmbox"] $workspace10
assign [class="Spotify"] $workspace10
assign [class="VirtualBox"] $workspace11
#################################################################
# /profiles/current/config.d/50-floating:
#------------------------------------------------
#
# floating windows
#
#------------------------------------------------
for_window [class="screengrab"] floating enable
for_window [class="osmo"] floating enable
for_window [class="gsimplecal"] floating enable
for_window [class="Osmo"] floating enable
for_window [class="Skype"] floating enable
for_window [class="Yad"] floating enable
#################################################################
# /profiles/current/config.d/90-exec:
#------------------------------------------------
#
# autostart - login command execution
#
#------------------------------------------------
# ensure that notification daemon is running
exec --no-startup-id dunst
# run window composer (with 2ms per step while faiding)
exec --no-startup-id compton -f -D 2
# enable touchpad with tapping and two-finger scroll
exec --no-startup-id synclient TouchpadOff=0
exec --no-startup-id synclient TapButton1=1
exec --no-startup-id synclient VertTwoFingerScroll=1
exec --no-startup-id synclient VertHysteresis=30
exec --no-startup-id synclient HorizHysteresis=30
# tune down screen colors with redshift
# exec --no-startup-id redshift -l 52.43:15.15 -m randr
# run network manager
exec --no-startup-id nm-applet
# run clipboard manager
#exec --no-startup-id bash -c "/usr/bin/clipit &"
exec --no-startup-id parcellite
# run bluetooth manager
#exec blueman-applet
# run tray icon with calendar
# other autostart apps
#exec terminator -p ratflow-terminator
#exec pcmanfm
#exec firefox
#exec thunderbird
#################################################################
# /profiles/current/config.d/91-exec_always:
#------------------------------------------------
#
# autostart - (re)load command execution
#
#------------------------------------------------
exec_always --no-startup-id xset dpms 600 600 600

77
.config/i3/py3status.conf

@ -0,0 +1,77 @@
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
output_format = "i3bar"
colors = true
interval = 10
}
order += "volume_status"
order += "diskdata"
order += "netdata"
order += "networkmanager"
order += "battery all"
order += "external_script top"
order += "sysdata mem"
order += "tztime local"
diskdata {
# disk = "/"
format = "{free}GB"
}
networkmanager {
# devices = ['e*'] # ethernet only
#devices = ['w*'] # wireless only
devices = ["*"]
format = "{format_device}"
format_device = "[{ip4_address1}]"
format_device_separator = " / "
}
external_script top {
cache_timeout = 10
script_path = "/usr/share/ratflow/scripts/top"
}
netdata {
cache_timeout = 5
format = '{nic}: [{down}↓ {up}↑]'
}
volume_status {
thresholds = [
(0, "#FF0000"),
(10, ""),
(100, "#FFFF00")
]
}
sysdata cpu {
cache_timeout = 5
format = "CPU: {cpu_used_percent}%"
}
sysdata mem {
cache_timeout = 5
format = " {mem_used_percent}%"
}
battery all {
format = "%status %percentage %remaining"
}
tztime local {
format = "%d-%m-%Y %H:%M"
}

13
.config/i3/scripts/always-float

@ -0,0 +1,13 @@
#!/bin/bash
currentClass=$(xprop -id $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) WM_CLASS | awk '{print $NF}')
# unquote
currentClass=$(eval echo $currentClass)
floatingDir="$HOME/.config/ratflow/profiles/current/config.d/floating.d"
mkdir -p "$floatingDir"
echo "for_window [class=\"${currentClass}\"] floating enable" > "$floatingDir/${currentClass}.float"
i3-msg floating enabled
rfreload

32
.config/i3/scripts/autoapp

@ -0,0 +1,32 @@
#!/usr/bin/python3
import subprocess, json, os
mapFile = open(os.environ['HOME'] + '/.config/ratflow/profiles/current/autoapp.conf', 'r');
map = json.loads(mapFile.read());
print(map)
def getCurrentWorkspaceNum():
command = "i3-msg -t get_workspaces"
proc = subprocess.Popen([command], stdout=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
jworkspaces = json.loads(out)
print(jworkspaces)
for workspace in jworkspaces:
if workspace['focused'] == True:
return workspace['num']
return False
workspaceNum = str(getCurrentWorkspaceNum())
if workspaceNum in map:
command = "i3-msg exec "+map[workspaceNum]
print ("running command: " + command)
proc = subprocess.Popen([command], stdout=subprocess.PIPE, shell=True)
else:
print("no application assigned to workspace " + workspaceNum)

21
.config/i3/scripts/backlight

@ -0,0 +1,21 @@
#!/bin/bash
set -x
if xbacklight -get; then
if [[ "$1" == "up" ]]; then
xbacklight -inc 20
else
xbacklight -dec 20
fi
else
val=$(cat /sys/class/backlight/*/brightness | head -1)
if [[ "$1" == "up" ]]; then
val=$((val+20))
else
val=$((val-20))
fi
for bk in /sys/class/backlight/*; do
echo $val > $bk/brightness
done
fi

102
.config/i3/scripts/bandwidth

@ -0,0 +1,102 @@
#!/bin/bash
# Copyright (C) 2012 Stefan Breunig <stefan+measure-net-speed@mathphys.fsk.uni-heidelberg.de>
# Copyright (C) 2014 kaueraal
# Copyright (C) 2015 Thiago Perrotta <perrotta dot thiago at poli dot ufrj dot br>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
############ ratflow edit ###########
# replace IN/OUT labels:
#inLabel=" "
#outLabel=" "
inLabel=" "
outLabel=" "
#######################################
# Use the provided interface, otherwise the device used for the default route.
if [[ -n $BLOCK_INSTANCE ]]; then
INTERFACE=$BLOCK_INSTANCE
else
INTERFACE=$(ip route | awk '/^default/ { print $5 ; exit }')
fi
# Issue #36 compliant.
if ! [ -e "/sys/class/net/${INTERFACE}/operstate" ] || [ "`cat /sys/class/net/${INTERFACE}/operstate`" == "down" ]
then
echo "$INTERFACE down"
echo "$INTERFACE down"
echo "#FF0000"
exit 0
fi
# path to store the old results in
path="/dev/shm/$(basename $0)-${INTERFACE}"
# grabbing data for each adapter.
read rx < "/sys/class/net/${INTERFACE}/statistics/rx_bytes"
read tx < "/sys/class/net/${INTERFACE}/statistics/tx_bytes"
# get time
time=$(date +%s)
# write current data if file does not exist. Do not exit, this will cause
# problems if this file is sourced instead of executed as another process.
if ! [[ -f "${path}" ]]; then
echo "${time} ${rx} ${tx}" > "${path}"
chmod 0666 "${path}"
fi
# read previous state and update data storage
read old < "${path}"
echo "${time} ${rx} ${tx}" > "${path}"
# parse old data and calc time passed
old=(${old//;/ })
time_diff=$(( $time - ${old[0]} ))
# sanity check: has a positive amount of time passed
[[ "${time_diff}" -gt 0 ]] || exit
# calc bytes transferred, and their rate in byte/s
rx_diff=$(( $rx - ${old[1]} ))
tx_diff=$(( $tx - ${old[2]} ))
rx_rate=$(( $rx_diff / $time_diff ))
tx_rate=$(( $tx_diff / $time_diff ))
# shift by 10 bytes to get KiB/s. If the value is larger than
# 1024^2 = 1048576, then display MiB/s instead
# incoming
echo -n "$inLabel"
rx_kib=$(( $rx_rate >> 10 ))
if [[ "$rx_rate" -gt 1048576 ]]; then
printf '%sM' "`echo "scale=1; $rx_kib / 1024" | bc`"
else
echo -n "${rx_kib}K"
fi
echo -n " "
# outgoing
echo -n "$outLabel"
tx_kib=$(( $tx_rate >> 10 ))
if [[ "$tx_rate" -gt 1048576 ]]; then
printf '%sM' "`echo "scale=1; $tx_kib / 1024" | bc`"
else
echo -n "${tx_kib}K"
fi

81
.config/i3/scripts/dmenu-i3-window-jumper

@ -0,0 +1,81 @@
#!/bin/sh
#description: dmenu-i3-window-jumper is a window selector for i3-wm
#usage: dmenu-i3-window-jumper is best suited to be launched from a shortcut (tab)
#example: dmenu-i3-window-jumper
#a gui menu appears asking which windows jump to
progname="$(expr "${0}" : '.*/\([^/]*\)')"
#variables are impractical to save complex cmds because of shell expantion
#therefore functions are required: http://mywiki.wooledge.org/BashFAQ/050
DMENU() { dmenu -p 'Jump to' -l 20 -i -fn Bahamas-10 \
-nb \#000000 -nf \#ffffff -sb \#c0c0c0 -sf \#000000; }
#looks better on xft powered dmenu:
#https://bugs.launchpad.net/ubuntu/+source/suckless-tools/+bug/1093745
_usage() {
printf "%s\\n" "Usage: ${progname} [app|title]"
printf "%s\\n" "Dmenu window selector for i3-wm."
printf "%s\\n"
printf "%s\\n" " -h, --help show this message and exit"
}
_die() {
[ -n "${1}" ] && _die_msg="${1}" || exit 1
printf "%b%b\\n" "${_die_msg}" ", press <Enter> to exit" | DMENU
exit 1
}
_i3_get_app_tree() {
i3-msg -t get_tree | \
egrep -o "(class\":\".[^\"]+\"|title\":\"[^\"]+)" | \
sed 's/"//g;s/class://g;s/title://g' | \
while read -r line; read -r line2; do \
printf "%s\\n" "═ ${line} :: ${line2}"; \
done | sed '/i3bar for/d'
#alternative
#i3-msg -t get_tree | python -mjson.tool | \
#sed -n -e 's/^ \{35\}[ ]\+\"name\": \"\(.*\)\", $/\1/p' | \
#sed '/^#[a-F0-9]\{6\}$/d'
}
if [ ! -t 0 ]; then
#add input comming from pipe or file to $@
set -- "${@}" $(cat)
fi
for arg in "${@}"; do #parse options
case "${arg}" in
-h|--help) _usage && exit ;;
esac
done
if [ -z "${1}" ]; then
if ! command -v "dmenu" >/dev/null 2>&1; then
printf "%s\\n" "${progname}: install 'dmenu' to run this program" >&2
exit 1
fi
selected_entry="$(_i3_get_app_tree | DMENU)"
else
selected_entry="$(_i3_get_app_tree | grep -i "${@}" 2>/dev/null | head -1 )"
fi
if [ -z "${selected_entry}" ]; then
_die
else
#escape some characters to prevent i3 to interpret them as a pattern
# "(" and ")" replace them with "\(" and "\)"
#title="$(printf "%s\\n" "${windows}" | sed 's/\([()]\)/\\\1/g')"
title="$(printf "%s\\n" "${selected_entry}" | \
egrep -o "::.*" | sed 's/:: //g;s/\([()]\)/\\\1/g')"
#focus window
output_msg="$(i3-msg "[title=\"${title}\"] focus" 2>&1)"
if printf "%s\\n" "${output_msg}" | tail -1 | \
grep "success" | grep "false" >/dev/null 2>&1; then
app="${title}"; i3-msg "[class=\"${app}\"] focus"
fi
fi

33
.config/i3/scripts/i3exit

@ -0,0 +1,33 @@
#!/bin/sh
lock() {
i3lock -n --color=000000
}
case "$1" in
lock)
lock
;;
logout)
i3-msg exit
;;
suspend)
gksu pm-suspend
;;
hibernate)
lock && dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Hibernate
/sbin/reboot
;;
reboot)
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
;;
shutdown)
#dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
/sbin/poweroff
;;
*)
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
exit 2
esac
exit 0

34
.config/i3/scripts/load_average

@ -0,0 +1,34 @@
#!/bin/sh
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# 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/>.
load="$(cut -d ' ' -f1 /proc/loadavg)"
cpus="$(nproc)"
# full text
echo "$load"
# short text
echo "$load"
# color if load is too high
awk -v cpus=$cpus -v cpuload=$load '
BEGIN {
if (cpus <= cpuload) {
print "#FF0000";
exit 33;
}
}
'

56
.config/i3/scripts/redshift-adjust

@ -0,0 +1,56 @@
#!/bin/bash
# redshift-adjust — Script for manually adjusting the colour temperature with hotkeys
# Copyright © 2014, 2015 Mattias Andrée (maandree@member.fsf.org)
# Copyright © 2015 "tPenguinLTG"
#
# 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/>.
file="/tmp/.${UID}.${DISPLAY}.redshift-adjust"
if [ ! $# = 1 ] || [ "${1}" = "-h" ] || [ "${1}" = "--help" ]; then
cat <<EOF
$0 =TEMP Set colour temperature to TEMP K
$0 +TEMP Increase colour temperature by TEMP K
$0 -TEMP Decrease colour temperature by TEMP K
$0 -p Print the current temperature
EOF
if [ $# = 1 ]; then
exit 0
fi
exit 1
fi
if [ ! -e "${file}" ]; then
echo 6500 > "${file}"
fi
if [ "${1}" = "-p" ] || [ "${1}" = "--print" ]; then
cat "${file}"
exit 0
fi
if [ "${1::1}" = "=" ]; then
temperature="${1:1}"
else
temperature=$(( $(cat "${file}") ${1::1} ${1:1} ))
fi
redshift -P -O $temperature || redshift -O $temperature
echo $temperature > "${file}"

30
.config/i3/scripts/top

@ -0,0 +1,30 @@
#!/bin/bash
# DANGER='\033[0;31m'
# WARNING='\033[1;33m'
# INFO='\033[0;34m'
# NC='\033[0m' # No Color
DANGER='#FF0000'
WARNING='#FFFF00'
INFO='#00FF00'
NC='' # No Color
topLine=$(top -b -n 1 | head -8 | tail -1)
topApp=$(echo -n $topLine | awk '{print $12}')
cpuLoad=$(echo -n $topLine | awk '{print $9}')
COLOR=$NC
cpuInt=$(printf "%.0f" $cpuLoad)
if [ $cpuInt -gt 80 ]; then
COLOR=$DANGER
elif [ $cpuInt -gt 50 ]; then
COLOR=$WARNING
fi
printf "${cpuLoad}%% ${topApp}\n${COLOR}\n"
exit 0

5693
.config/i3/scripts/trans

File diff suppressed because it is too large Load Diff

12
.config/i3/scripts/trans-xsel

@ -0,0 +1,12 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
srcTarget=$1
text=$(xsel)
#trim
text=${text##*( )}
text=${text%%*( )}
trResult=$($SCRIPT_DIR/trans -b $srcTarget "${text}")
notify-send -t 20000 "$(echo -e "Selected text translation ${srcTarget^^}: \n${trResult}")"

30
.config/i3/scripts/volctl

@ -0,0 +1,30 @@
#!/bin/bash
set -x
cmd=$1
sink=$VOLCTL_SINK
# if VOLCTL_SINK is not set, use the sink that was most recently connected
if [ -z "$sink" ]; then
NUM=${VOLCTL_SINK_NUM:-1}
sink=$(pactl list sinks | grep "Name:" | awk '{print $2}' | sed "${NUM}q;d")
fi
case $cmd in
up | u)
pactl set-sink-volume $sink +5%
;;
down | d)
pactl set-sink-volume $sink -5%
;;
toggle | t)
pactl set-sink-mute $sink toggle
;;
*)
echo -n "unknown command: $cmd"
;;
esac

70
.config/i3/scripts/volume_auto

@ -0,0 +1,70 @@
#!/bin/bash
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# Copyright (C) 2014 Alexander Keller <github@nycroth.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------------------
# The second parameter overrides the mixer selection
# For PulseAudio users, use "pulse"
# For Jack/Jack2 users, use "jackplug"
# For ALSA users, you may use "default" for your primary card
# or you may use hw:# where # is the number of the card desired
MIXER="default"
# [ -n "$(ps -x | grep -v grep | grep pulseaudio)" ] && MIXER="pulse"
# [ -n "$(lsmod | grep jack)" ] && MIXER="jackplug"
# MIXER="${2:-$MIXER}"
# The instance option sets the control to report and configure
# This defaults to the first control of your selected mixer
# For a list of the available, use `amixer -D $Your_Mixer scontrols`
SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols |
sed -n "s/Simple mixer control '\([A-Za-z ]*\)',0/\1/p" |
head -n1
)}"
# The first parameter sets the step to change the volume by (and units to display)
# This may be in in % or dB (eg. 5% or 3dB)
STEP="${1:-5%}"
#------------------------------------------------------------------------
capability() { # Return "Capture" if the device is a capture device
amixer -D $MIXER get $SCONTROL |
sed -n "s/ Capabilities:.*cvolume.*/Capture/p"
}
volume() {
amixer -D $MIXER get $SCONTROL $(capability)
}
format() {
perl_filter='if (/.*\[(\d+%)\] (\[(-?\d+.\d+dB)\] )?\[(on|off)\]/)'
perl_filter+='{CORE::say $4 eq "off" ? "MUTE" : "'
# If dB was selected, print that instead
perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1')
perl_filter+='"; exit}'
perl -ne "$perl_filter"
}
#------------------------------------------------------------------------
case $BLOCK_BUTTON in
3) amixer -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute
4) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase
5) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease
esac
volume | format
Loading…
Cancel
Save