diff --git a/i3/config b/i3/config new file mode 100644 index 0000000..8ef4d5c --- /dev/null +++ b/i3/config @@ -0,0 +1,352 @@ +# This file has been auto-generated by i3-config-wizard(1). +# It will not be overwritten, so edit it as you like. +# +# Should you change your keyboard layout some time, delete +# this file and re-run i3-config-wizard(1). +# + +# i3 config file (v4) +# +# Please see https://i3wm.org/docs/userguide.html for a complete reference! + +#export TERMINAL="terminology" + +set $mod Mod4 +set $term --nostartup-id $TERM + +# Configure border style +new_window pixel 2 +new_float pixel 2 + +# Hide borders +hide_edge_borders none + +# 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 7 + +# 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 15px + +# 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. + +set $term --no-startup-id $TERM + +# Autostart Programs + +#exec i3-style default -o ~/.config/i3/config --reload +exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 & eval $(gnome-keyring-daemon -s --components=pkcs11,secrets,ssh,gpg) +exec nitrogen --restore +exec sh ~/.screenlayout/maintriple.sh +exec --no-startup-id nm-applet +#exec conky -c ~/.conky/Titus.conkyrc +exec mpd +exec compton +exec curl ifconfig.co/city > ~/.city +exec curl ifconfig.co/country > ~/.country +#exec hp-toolbox + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod + +# start a terminal +bindsym $mod+Return exec kitty + +# kill focused window +bindsym $mod+Shift+q kill + +# start rofi/dmenu (a program launcher) +bindsym $mod+d exec "rofi -combi-modi window,drun,ssh,run -show combi -modi combi -run-shell-command 'kitty -e {cmd}'" +# 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 + +#Launch pulsemixer +bindsym $mod+Shift+p exec kitty -c ~/.config/kitty/kittyweather.conf -e pulsemixer + +#Webcam open +bindsym $mod+Shift+w exec --no-startup-id camtoggle + +#Screenrecording +bindsym $mod+t exec screencast +bindsym $mod+Shift+t exec bash screencastkill + +#YouTube MPS +bindsym $mod+y exec kitty -e mpsyt + +#Music Player NCMPCPP +bindsym $mod+n exec kitty -e ncmpcpp + + +# 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 + +# Open Neomutt Email +bindsym $mod+m exec kitty -e neomutt + +# Open IRC Chat +bindsym $mod+i exec kitty -e irssi + +# + +# Open Finch IM +# bindsym $mod+f exec kitty -e finch + +# Define names for default workspaces for which we configure key bindings later on. +# We use variables to avoid repeating the names in multiple places. +set $ws1 1: +set $ws2 "2" +set $ws3 "3" +set $ws4 "4" +set $ws5 "5" +set $ws6 "6" +set $ws7 "7" +set $ws8 "8" +set $ws9 "9" +set $ws10 "10" + + +# switch to workspace +bindsym $mod+1 workspace $ws1 +bindsym $mod+2 workspace $ws2 +bindsym $mod+3 workspace $ws3 +bindsym $mod+4 workspace $ws4 +bindsym $mod+5 workspace $ws5 +bindsym $mod+6 workspace $ws6 +bindsym $mod+7 workspace $ws7 +bindsym $mod+8 workspace $ws8 +bindsym $mod+9 workspace $ws9 +bindsym $mod+0 workspace $ws10 + +# move focused container to workspace +bindsym $mod+Shift+1 move container to workspace $ws1 +bindsym $mod+Shift+2 move container to workspace $ws2 +bindsym $mod+Shift+3 move container to workspace $ws3 +bindsym $mod+Shift+4 move container to workspace $ws4 +bindsym $mod+Shift+5 move container to workspace $ws5 +bindsym $mod+Shift+6 move container to workspace $ws6 +bindsym $mod+Shift+7 move container to workspace $ws7 +bindsym $mod+Shift+8 move container to workspace $ws8 +bindsym $mod+Shift+9 move container to workspace $ws9 +bindsym $mod+Shift+0 move container to workspace $ws10 + +# reload the configuration file +bindsym $mod+Shift+c reload +# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) +bindsym $mod+Shift+r restart +# exit i3 (logs you out of your X session) +bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'" + +# 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 or $mod+r + bindsym Return mode "default" + bindsym Escape mode "default" + bindsym $mod+r mode "default" +} + +bindsym $mod+r mode "resize" + +set $bg-color #2f343f +set $inactive-bg-color #2f343f +set $text-color #f3f4f5 +set $inactive-text-color #676E7D +set $urgent-bg-color #E53935 + +# window colors +# border background text indicator + +# Start i3bar to display a workspace bar (plus the system information i3status +# finds out, if available) +bar { +bindsym button3 exec "rofi -combi-modi window,drun,ssh,run -show combi -modi combi -run-shell-command 'kitty -e {cmd}'" + i3bar_command i3bar --transparency + +#Uncomment below to use custom config +#status_command i3status +#Uncomment below to use i3blocks +status_command i3blocks -c ~/.config/i3/i3blocks.conf + position top + mode dock + modifier None + font pango:Inconsolata Nerd Font 11 + colors { + separator #2195F2 + background #00000000 + statusline #ffffff + focused_workspace #00000000 #00000000 #ffffff + active_workspace #00000000 #00000000 #ffffff + inactive_workspace #00000000 #00000000 #888888 + urgent_workspace #2f343a #900000 #ffffff + } + + separator_symbol " " +} + +############################# +### settings for i3-gaps: ### +############################# + +# Set inner/outer gaps +gaps inner 14 +gaps outer -2 + +# Pulse Audio controls +bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5% #increase sound volume +bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5% #decrease sound volume +bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # mute sound + +# Sreen brightness controls +bindsym XF86MonBrightnessUp exec xbacklight -inc 20 # increase screen brightness +bindsym XF86MonBrightnessDown exec xbacklight -dec 20 # decrease screen brightness + +# Touchpad controls +bindsym XF86TouchpadToggle exec /some/path/toggletouchpad.sh # toggle touchpad + +# Media player controls +bindsym XF86AudioPlay exec playerctl play +bindsym XF86AudioPause exec playerctl pause +bindsym XF86AudioNext exec playerctl next +bindsym XF86AudioPrev exec playerctl previousb + +# Open specific applications in floating mode +for_window [class="Nitrogen"] floating enable sticky enable border pixel 1 +for_window [class="Lxappearance"] floating enable sticky enable border pixel 1 +for_window [class="qt5ct"] floating enable sticky enable border pixel 1 +for_window [class="Pavucontrol"] floating enable +for_window [title="alsamixer"] floating enable border pixel 1 +for_window [class="Pamac-manager"] floating enable +#for_window [class="(?i)virtualbox"] floating enable border pixel 1 +for_window [title="urxvt"] floating enable border pixel 1 +for_window [class="urxvt"] floating enable border pixel 1 +#for_window [title="xterm"] floating enable border pixel 1 +for_window [class="st"] floating enable border pixel 1 +for_window [class="terminology"] floating enable pixel 1 +for_window [class="kitty"] floating enable pixel 1 +for_window [title="kitty"] floating enable pixel 1 +for_window [title="kitty"] floating enable +#for_window [title="sakura"] floating enable pixel 1 +#for_window [class="sakura"] floating enable pixel 1 +for_window [title="video2 - mpv"] floating enable +for_window [title="video2 - mpv"] sticky enable +for_window [title="mpv"] floating enable pixel 1 +for_window [class="mpv"] floating enable pixel 1 +for_window [class="kitty"] floating enable pixel 1 +for_window [title="kitty"] floating enable pixel 1 +for_window [title="kitty"] floating enable +for_window [title="xterm"] floating enable +for_window [title="xterm"] floating enable pixel 1 + + +#Disable Floating for Vivaldi +for_window [title="vivaldi-stable"] floating disable + + +# Workspace names +# to display names or symbols instead of plain workspace numbers you can use +# something like: set $ws1 1:mail +# set $ws2 2: +set $ws1 1 +set $ws2 2 +set $ws3 3 +set $ws4 4 +set $ws5 5 +set $ws6 6 +set $ws7 7 +set $ws8 8 + +#navigate workspaces next / previous +bindsym $mod+Ctrl+Right workspace next +bindsym $mod+Ctrl+Left workspace prev + +#Open conf files +bindsym $mod+c exec kitty -e nvim ~/.config/i3/config +bindsym $mod+Shift+b exec kitty -e nvim ~/.config/i3/i3blocks.conf + +#Screenshot +bindsym Print exec xfce4-screenshooter + +#toggle htop +bindsym $mod+Shift+h exec kitty -e htop + +#toggle ranger +bindsym $mod+Shift+f exec kitty -e ranger + +#nvidia monitor +bindsym $mod+Shift+n exec kitty -c ~/.config/kitty/kittyweather.conf -e watch nvidia-smi + +client.focused #4c7899 #285577 #ffffff #2e9ef4 +client.focused_inactive #333333 #5f676a #ffffff #484e50 +client.unfocused #333333 #222222 #888888 #292d2e +client.urgent #2f343a #900000 #ffffff #900000 diff --git a/i3/i3blocks.conf b/i3/i3blocks.conf new file mode 100644 index 0000000..9516a82 --- /dev/null +++ b/i3/i3blocks.conf @@ -0,0 +1,306 @@ +# i3blocks config file +# +# 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 +# background +# border +# 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. +# Each block command defaults to the script name to avoid boilerplate. +command=/usr/lib/i3blocks/$BLOCK_NAME +separator_block_width=0 +markup=pango + +#[distro] +#instance=distro +#label= +#interval=once +#color=#00FF00 + +#[hostname] +#instance=hostname +#interval=once +#color=#FFFFFF + +[separator11] +full_text= +align=left +border=#00000000 +border_top=1 +border_bottom=2 +border_right=0 +border_left=0 +markup=pango + +[news] +label=📰 +interval=once +signal=6 +background=#b7482299 +#color=#FFFFFF + +[separator10] +full_text= +align=left +border=#b7482299 +border_top=1 +border_bottom=2 +border_right=0 +border_left=0 +markup=pango + +[weather] +instance=weather +interval=3600 +background=#7b88d399 +#color=#FFFFFF + +[separator9] +full_text= +align=left +border=#7b88d399 +border_top=1 +border_bottom=2 +border_right=0 +border_left=0 +markup=pango + +#[mail] +#instance=mail +#label=📬 +#interval=180 +#signal=12 +#color=#FFFFFF + +[iface] +label=🌐 +#instance=wlan0 +#color=# +interval=10 +background=#777E7699 +separator=false + +[i3wifi] +instance=wlp3s0 +#instance=wlp0s16u2 +#instance=wlp0s16u1 +#instance=wlp0s29u1u5 +#instance=wlp0s26u1u2 +interval=10 +background=#777E7699 +#color=#FFFFFF + +[separator8] +full_text= +align=left +border=#777E7699 +border_top=1 +border_bottom=2 +border_right=0 +border_left=0 +markup=pango + +[memory] +label=🧠 +#separator=false +interval=30 +background=#8DAA9A99 +#color=#FFFFFF + +[separator7] +full_text= +align=left +border=#8DAA9A99 +border_top=1 +border_bottom=2 +border_right=0 +border_left=0 +markup=pango + +#[publicip] +#label=🌐 +#instance=publicip +#interval=300 +#color=#FFFFFF + +#[publicipv6] +#label=🌐 +#instance=publicipv6 +#interval=300 +#color=#FFFFFF + +#[bandwidth] +#instance=eth0 +#interval=5 + +[cpu_usage] +label=💻 +interval=10 +#min_width=CPU: 100.00% +background=#CB755B99 +#color=#FFFFFF +#separator=false + +[separator6] +full_text= +align=left +border=#CB755B99 +border_top=1 +border_bottom=2 +border_right=0 +border_left=0 +markup=pango + +[disk_usage] +interval=60 +command=disk_usage / +background=#4B3B5199 +#color=#FFFFFF + +[disk_usage] +interval=60 +command=disk_usage /home 🏠 +background=#4B3B5199 +#color=#FFFFFF + +[separator5] +full_text= +align=left +border=#4B3B5199 +border_top=1 +border_bottom=2 +border_right=0 +border_left=0 +markup=pango + +#[kernel] +#label= +#instance=kernel +#interval=once +#color=#FFFFFF + +#[load_average] +#interval=10 + +[battery] +label=⚡ +instance=0 +interval=5 +background=#889FA799 +#color=#FFFFFF + +[separator4] +full_text= +align=left +border=#889FA799 +border_top=1 +border_bottom=2 +border_right=0 +border_left=0 +markup=pango + +#[country] +#label=🌐 +#instance=country +#interval=43200 +#color=#FFFFFF + +#[city] +#label=🌐 +#instance=city +#interval=43200 +##color=#FFFFFF + +[i3volume] +instance=i3volume +interval=once +signal=10 +background=#497B9699 +#color=#FFFFFF + +[separator3] +full_text= +align=left +border=#497B9699 +border_top=1 +border_bottom=2 +border_right=0 +border_left=0 +markup=pango + +[music] +label=🎼 +command=/usr/lib/i3blocks/music +instance=mpd +interval=5 +signal=10 +background=#21F3EC99 +#color=#FFFFFF + +[separator2] +full_text= +align=left +border=#21F3EC99 +border_top=1 +border_bottom=2 +border_right=0 +border_left=0 +markup=pango + +[record] +label= +instance=record +interval=2 +background=#889FA799 +color=#FF0000 + +[torrent] +interval=20 +signal=7 +background=#889FA799 +#color=#FFFFFF + +[i3pacman] +label=📦 +interval=43200 +signal=8 +background=#889FA799 +border=#889FA799 +#color=#FFFFFF + +[time] +label=📅 +command=echo $(date '+%Y %b %d (%a) %I:%M%p') 🕓 +interval=1 +background=#889FA799 +#color=#FFFFFF + +[separator1] +full_text= +align=left +border=#889FA799 +border_top=1 +border_bottom=2 +border_right=0 +border_left=0 +markup=pango + diff --git a/i3/i3blocks.conf.backup b/i3/i3blocks.conf.backup new file mode 100644 index 0000000..1ad9231 --- /dev/null +++ b/i3/i3blocks.conf.backup @@ -0,0 +1,303 @@ +# i3blocks config file +# +# 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. +# Each block command defaults to the script name to avoid boilerplate. +command=/usr/lib/i3blocks/$BLOCK_NAME +separator_block_width=15 +markup=pango + +#[distro] +#instance=distro +#label= +#interval=once +#color=#00FF00 + +[hostname] +instance=hostname +interval=once +#color=#FFFFFF + +[kernel] +instance=kernel +interval=once +#color=#FFFFFF + +[news] +label=📰 +interval=once +signal=6 +#color=#FFFFFF + + +[weather] +instance=weather +interval=3600 +#color=#FFFFFF + + +#Weather + +#[weather2] +#instance=weather2 +#interval=120 +#color=#FFFFFF + + +#[mail] +#instance=mail +#label=📬 +#interval=180 +#signal=12 +#color=#FFFFFF + + + +# Volume indicator +# +# The first parameter sets the step (and units to display) +# The second parameter overrides the mixer selection +# See the script for details. +[i3volume] +#label=VOL +label=♪ +instance=i3volume +#instance=PCM +interval=once +signal=10 +#color=#FFFFFF + +[record] +label= +instance=record +interval=2 +color=#FF0000 + + +#[volume] +#instance=Master +#interval=once +#command=i3volume +#signal=10 + +[mediaplayer] +label=♪ +command=/usr/lib/i3blocks/mediaplayer +instance=mpd +interval=5 +signal=10 +#color=#FFFFFF + +# Memory usage +# +# The type defaults to "mem" if the instance is not specified. +[memory] +label=🧠 +#separator=false +interval=30 +#color=#FFFFFF + +#[memory] +#label=SWAP +#instance=swap +#separator=false +#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=HOME +#instance=/mnt/data +#interval=30 + +# Network interface monitoring +# +# If the instance is not specified, use the interface used for default route. +# The address can be forced to IPv4 or IPv6 with -4 or -6 switches. +[iface] +label=🌐 +#instance=wlan0 +#color=# +interval=10 +separator=false + +#[wifi] +#instance=wlp3s0 +#interval=10 +#separator=false + +[i3wifi] +instance=wlp3s0 +#instance=wlp0s16u2 +#instance=wlp0s16u1 +#instance=wlp0s29u1u5 +#instance=wlp0s26u1u2 +interval=10 +#color=#FFFFFF + +#[publicip] +#label=🌐 +#instance=publicip +#interval=300 +#color=#FFFFFF + +[publicipv6] +label=🌐 +instance=publicipv6 +interval=300 +#color=#FFFFFF + +#[bandwidth] +#instance=eth0 +#interval=5 + +# CPU usage +# +# The script may be called with -w and -c switches to specify thresholds, +# see the script for details. +[cpu_usage] +label=💻 +interval=10 +min_width=CPU: 100.00% +#color=#FFFFFF +#separator=false + +#[record] +#command=cat /tmp/recordingicon +#interval=once +#signal=9 + +#[music] +#label=🎼 +#interval=once +#signal=11 + +[disk_usage] +interval=60 +command=disk_usage / +#color=#FFFFFF + +[disk_usage] +interval=60 +command=disk_usage /home 🏠 +#color=#FFFFFF + +[torrent] +interval=20 +signal=7 +#color=#FFFFFF + +#[load_average] +#interval=10 + +# Battery indicator +# +# The battery instance defaults to 0. +[battery] +#label=BAT +label=⚡ +instance=0 +interval=5 +#color=#FFFFFF + + + +#[i3battery] +#command=i3battery +#interval=5 + +[i3pacman] +label=📦 +interval=43200 +signal=8 +#color=#FFFFFF + +#[country] +#label=🌐 +#instance=country +#interval=43200 +#color=#FFFFFF + +[city] +label=🌐 +instance=city +interval=43200 +#color=#FFFFFF + + +# Date Time +# +#[time] +#command=date '+%Y-%m-%d %r' +#interval=1 + +[time] +label=📅 +command=echo $(date '+%Y %b %d (%a) %I:%M%p') 🕓 +interval=1 +#color=#FFFFFF + + +# Generic media player support +# +# This displays "ARTIST - SONG" if a music is playing. +# Supported players are: spotify, vlc, audacious, xmms2, mplayer, and others. +#[mediaplayer] +#instance=vlc +#interval=5 +#signal=10 + +# OpenVPN support +# +# Support multiple VPN, with colors. +#[openvpn] +#interval=20 + +# Temperature +# +# Support multiple chips, though lm-sensors. +# The script may be called with -w and -c switches to specify thresholds, +# see the script for details. +#[temperature] +#label=TEMP +#interval=10 + +# Key indicators +# +# Add the following bindings to i3 config file: +# +# bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks +# bindsym --release Num_Lock exec pkill -SIGRTMIN+11 i3blocks +#[keyindicator] +#instance=CAPS +#interval=5 +#signal=11 + +#[keyindicator] +#instance=NUM +#interval=5 +#signal=11 diff --git a/i3blocks/bandwidth b/i3blocks/bandwidth new file mode 100644 index 0000000..d9d3ab2 --- /dev/null +++ b/i3blocks/bandwidth @@ -0,0 +1,90 @@ +#!/bin/bash +# Copyright (C) 2012 Stefan Breunig +# Copyright (C) 2014 kaueraal +# Copyright (C) 2015 Thiago Perrotta + +# 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 the provided interface, otherwise the device used for the default route. +if [[ -n $BLOCK_INSTANCE ]]; then + INTERFACE=$BLOCK_INSTANCE +else + INTERFACE=$(ip route | awk '/^default/ { print $5 ; exit }') +fi + +# Issue #36 compliant. +if ! [ -e "/sys/class/net/${INTERFACE}/operstate" ] || ! [ "`cat /sys/class/net/${INTERFACE}/operstate`" = "up" ] +then + echo "$INTERFACE down" + echo "$INTERFACE down" + echo "#FF0000" + exit 0 +fi + +# path to store the old results in +path="/dev/shm/$(basename $0)-${INTERFACE}" + +# grabbing data for each adapter. +read rx < "/sys/class/net/${INTERFACE}/statistics/rx_bytes" +read tx < "/sys/class/net/${INTERFACE}/statistics/tx_bytes" + +# get time +time=$(date +%s) + +# write current data if file does not exist. Do not exit, this will cause +# problems if this file is sourced instead of executed as another process. +if ! [[ -f "${path}" ]]; then + echo "${time} ${rx} ${tx}" > "${path}" + chmod 0666 "${path}" +fi + +# read previous state and update data storage +read old < "${path}" +echo "${time} ${rx} ${tx}" > "${path}" + +# parse old data and calc time passed +old=(${old//;/ }) +time_diff=$(( $time - ${old[0]} )) + +# sanity check: has a positive amount of time passed +[[ "${time_diff}" -gt 0 ]] || exit + +# calc bytes transferred, and their rate in byte/s +rx_diff=$(( $rx - ${old[1]} )) +tx_diff=$(( $tx - ${old[2]} )) +rx_rate=$(( $rx_diff / $time_diff )) +tx_rate=$(( $tx_diff / $time_diff )) + +# shift by 10 bytes to get KiB/s. If the value is larger than +# 1024^2 = 1048576, then display MiB/s instead + +# incoming +echo -n "IN " +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 "OUT " +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 diff --git a/i3blocks/battery b/i3blocks/battery new file mode 100644 index 0000000..3af2b44 --- /dev/null +++ b/i3blocks/battery @@ -0,0 +1,74 @@ +#!/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 $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 .= ' 🔋'; +} elsif ($status eq 'Charging') { + $full_text .= ' 🔌'; +} + +$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/i3blocks/city b/i3blocks/city new file mode 100644 index 0000000..51718cf --- /dev/null +++ b/i3blocks/city @@ -0,0 +1,6 @@ +#/usr/bin/bash + +#Make sure that this is run at least once when i3 starts: "curl ifconfig.co/city > ~/.city" +#I make it a start up process in my i3 config file. + +printf "$(cat ~/.city)" diff --git a/i3blocks/country b/i3blocks/country new file mode 100644 index 0000000..80bab2d --- /dev/null +++ b/i3blocks/country @@ -0,0 +1,7 @@ +#/usr/bin/bash + +#Make sure that this is run at least once when i3 starts: "curl ifconfig.co/country > ~/.country" +#I make it a start up process in my i3 config file. + + +printf "$(cat ~/.country)" diff --git a/i3blocks/cpu_usage b/i3blocks/cpu_usage new file mode 100644 index 0000000..8c3c1f5 --- /dev/null +++ b/i3blocks/cpu_usage @@ -0,0 +1,55 @@ +#!/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 = 50; +my $t_crit = 80; +my $cpu_usage = -1; + +sub help { + print "Usage: cpu_usage [-w ] [-c ]\n"; + print "-w : warning threshold to become yellow\n"; + print "-c : critical threshold to become red\n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit); + +# 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+$/) { + $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 +printf "%.2f%%\n", $cpu_usage; +printf "%.2f%%\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/i3blocks/disk_usage b/i3blocks/disk_usage new file mode 100644 index 0000000..e2d25c0 --- /dev/null +++ b/i3blocks/disk_usage @@ -0,0 +1,19 @@ + +#!/bin/sh + +# Status bar module for disk space +# $1 should be drive mountpoint +# $2 is optional icon, otherwise mountpoint will displayed + +[ -z "$1" ] && exit + +icon="$2" +[ -z "$2" ] && icon="$1" + +case $BLOCK_BUTTON in + 1) pgrep -x dunst >/dev/null && notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;; + 3) pgrep -x dunst >/dev/null && notify-send "💽 Disk module" "\- Shows used hard drive space. +- Click to show all disk info." ;; +esac + +printf "%s: %s" "$icon" "$(df -h "$1" | awk ' /[0-9]/ {print $3 "/" $2}')" diff --git a/i3blocks/hostname b/i3blocks/hostname new file mode 100644 index 0000000..2124081 --- /dev/null +++ b/i3blocks/hostname @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +printf("$(cat /etc/hostname)") diff --git a/i3blocks/i3pacman b/i3blocks/i3pacman new file mode 100644 index 0000000..0a2f7b5 --- /dev/null +++ b/i3blocks/i3pacman @@ -0,0 +1,17 @@ +#!/bin/sh + +# i3blocks module for pacman upgrades. +# Displays number of upgradeable packages. +# For this to work, have a `pacman -Sy` command run in the background as a +# cronjob every so often as root. This script will then read those packages. +# When clicked, it will run an upgrade via `yay`. (`yay` required, duh.) + +case $BLOCK_BUTTON in + 1) kitty -c ~/.config/kitty/kittyweather.conf -e yay -Syyu && pacman -Qu | wc -l > ~/.pacupgrnum && pkill -RTMIN+8 i3blocks ;; +esac + +pacman -Qu | wc -l | sed -e '/^0$/d' > ~/.pacupgrnum && pkill -RTMIN+8 i3blocks + +sed -e "/^$/d" ~/.pacupgrnum + +notify-send "You have $(cat ~/.pacupgrnum) updates" diff --git a/i3blocks/i3volume b/i3blocks/i3volume new file mode 100644 index 0000000..0c2ec93 --- /dev/null +++ b/i3blocks/i3volume @@ -0,0 +1,12 @@ +#!/bin/bash + +case $BLOCK_BUTTON in + 1) kitty -c /home/angelp/.config/kitty/kittyweather.conf -e pulsemixer & disown ;; + 3) pamixer -t ;; + 4) pamixer -i 5 ;; + 5) pamixer -d 5 ;; +esac + +printpastatus() { [[ $(pamixer --get-mute) = "true" ]] && echo -n 🔇 && exit +echo 🔊 $(pamixer --get-volume)% ;} +printpastatus diff --git a/i3blocks/i3wifi b/i3blocks/i3wifi new file mode 100644 index 0000000..2b05de3 --- /dev/null +++ b/i3blocks/i3wifi @@ -0,0 +1,25 @@ +#!/bin/bash + +case $BLOCK_BUTTON in + 1) $TERMINAL -e sudo -A wifi-menu ;; +esac + +INTERFACE="${BLOCK_INSTANCE:-wlan0}" + +[[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && echo 📡 && exit + +QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') + +echo 📶 $QUALITY% +echo 📶 $QUALITY% + +# color +if [[ $QUALITY -ge 80 ]]; then + echo "#00FF00" +elif [[ $QUALITY -lt 80 ]]; then + echo "#FFF600" +elif [[ $QUALITY -lt 60 ]]; then + echo "#FFAE00" +elif [[ $QUALITY -lt 40 ]]; then + echo "#FF0000" +fi \ No newline at end of file diff --git a/i3blocks/iface b/i3blocks/iface new file mode 100644 index 0000000..7014979 --- /dev/null +++ b/i3blocks/iface @@ -0,0 +1,61 @@ +#!/bin/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 . + +#------------------------------------------------------------------------ + +# Use the provided interface, otherwise the device used for the default route. +if [[ -n $BLOCK_INSTANCE ]]; then + IF=$BLOCK_INSTANCE +else + IF=$(ip route | awk '/^default/ { print $5 ; exit }') +fi + +#------------------------------------------------------------------------ + +# As per #36 -- It is transparent: e.g. if the machine has no battery or wireless +# connection (think desktop), the corresponding block should not be displayed. +[[ ! -d /sys/class/net/${IF} ]] && exit + +#------------------------------------------------------------------------ + +if [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then + echo down # full text + echo down # short text + echo \#FF0000 # color + exit +fi + +case $1 in + -4) + AF=inet ;; + -6) + AF=inet6 ;; + *) + AF=inet6? ;; +esac + +# if no interface is found, use the first device with a global scope +IPADDR=$(ip addr show $IF | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit") + +case $BLOCK_BUTTON in + 3) echo -n "$IPADDR" | xclip -q -se c ;; +esac + +#------------------------------------------------------------------------ + +echo "$IPADDR" # full text +echo "$IPADDR" # short text diff --git a/i3blocks/kernel b/i3blocks/kernel new file mode 100644 index 0000000..00ebe78 --- /dev/null +++ b/i3blocks/kernel @@ -0,0 +1,5 @@ +#!/usr/bin/bash + +printf "$(uname -r)" + + diff --git a/i3blocks/news b/i3blocks/news new file mode 100644 index 0000000..92b4589 --- /dev/null +++ b/i3blocks/news @@ -0,0 +1,17 @@ +#!/bin/sh + +# i3blocks newsboat module. +# Displays number of unread news items and an loading icon if updating. +# When clicked, brings up `newsboat`. + +case $BLOCK_BUTTON in + 1) setsid kitty -c ~/.config/kitty/kittyweather.conf -e newsboat ;; + 2) setsid newsup >/dev/null & exit ;; + 3) pgrep -x dunst >/dev/null && notify-send "📰 News module" "\- Shows unread news items +- Shows 🔃 if updating with \`newsup\` +- Left click opens newsboat +- Middle click syncs RSS feeds +Note: Only one instance of newsboat (including updates) may be running at a time." ;; +esac + +cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ print $1}' | sed s/^0$//g)$(cat ~/.config/newsboat/.update 2>/dev/null)" diff --git a/i3blocks/popweather b/i3blocks/popweather new file mode 100644 index 0000000..b7ce75e --- /dev/null +++ b/i3blocks/popweather @@ -0,0 +1,2 @@ +#!/bin/bash +cat ~/.weatherreport && read \ No newline at end of file diff --git a/i3blocks/publicipv6 b/i3blocks/publicipv6 new file mode 100644 index 0000000..7617cc3 --- /dev/null +++ b/i3blocks/publicipv6 @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +printf "$(curl ifconfig.co)" diff --git a/i3blocks/record b/i3blocks/record new file mode 100644 index 0000000..a39cf24 --- /dev/null +++ b/i3blocks/record @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail + +# check screemcast PID + +PIDFILE="~/.screencast.pid" + +if [[ -e "${PIDFILE}" ]]; then + + echo "RECORD" + echo "RECORD" + echo "" + +fi diff --git a/i3blocks/screencast b/i3blocks/screencast new file mode 100644 index 0000000..aab3266 --- /dev/null +++ b/i3blocks/screencast @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# start|stop screencast + +set -o errexit +set -o pipefail + +PIDFILE="${HOME}/.screencast.pid" +OUTFILE="/tmp/out.mkv" +FINALFILE="${HOME}/Videos/ScreenCasts/screencast--$(date +'%Y-%m-%d--%H-%M-%S').mkv" + +# check if this script is already running +if [ -s $PIDFILE ] && [ -d "/proc/$(cat $PIDFILE)" ]; then + + # send SIG_TERM to screen recorder + kill $(cat $PIDFILE) + + # clear the pidfile + rm $PIDFILE + + # move the screencast into the user's video directory + mv $OUTFILE $FINALFILE +else + # screen resolution + SCREENRES=$(xrandr -q --current | grep '*' | awk '{print$1}') + + # write to the pidfile + echo $$ > $PIDFILE && + + # let the recording process take over this pid + exec ffmpeg \ + -f pulse \ + -i default \ + -ac 2 \ + -acodec vorbis \ + -f x11grab \ + -r 25 \ + -s ${SCREENRES} \ + -i :0.0 \ + -vcodec libx264 ${OUTFILE} +fi diff --git a/i3blocks/torrent b/i3blocks/torrent new file mode 100644 index 0000000..8b612a1 --- /dev/null +++ b/i3blocks/torrent @@ -0,0 +1,27 @@ +#!/bin/sh + +transmission-remote -l | grep % | + sed " # This first sed command is to ensure a desirable order with sort + s/.*Stopped.*/A/g; + s/.*Seeding.*/Z/g; + s/.*100%.*/N/g; + s/.*Idle.*/B/g; + s/.*Uploading.*/L/g; + s/.*%.*/M/g" | + sort -h | uniq -c | sed " # Now we replace the standin letters with icons. + s/A/🛑/g; + s/B/⌛️/g; + s/L/🔼/g; + s/M/🔽/g; + s/N/✅/g; + s/Z/🌱/g" | awk '{print $2, $1}' | tr '\n' ' ' | sed -e "s/ $//g" + +case $BLOCK_BUTTON in + 1) kitty -e transmission-remote-cli ;; + 3) pgrep -x dunst >/dev/null && notify-send "Torrent module" "🛑: paused +⏳: idle (seeds needed) +🔼: uploading (unfinished) +🔽: downloading +✅: done +🌱: done and seeding" ;; +esac diff --git a/i3blocks/weather b/i3blocks/weather new file mode 100644 index 0000000..c532385 --- /dev/null +++ b/i3blocks/weather @@ -0,0 +1,15 @@ +#!/bin/sh +### This is only if your location isn't automatically detected, otherwise you can leave it blank. +location="West_Springfield,Massachusetts" + +[ "$location" != "" ] && location="$location+" +[ "$BLOCK_BUTTON" = "1" ] && kitty -c ~/.config/kitty/kittyweather.conf -e /usr/lib/i3blocks/popweather + +ping -q -w 1 -c 1 "$(ip r | grep default | tail -1 | cut -d ' ' -f 3)" >/dev/null || exit + +curl -s wttr.in/$location > ~/.weatherreport + +printf "%s" "$(sed '16q;d' ~/.weatherreport | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')" + +sed '13q;d' ~/.weatherreport | grep -o "m[0-9]\\+" | sort -n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","☀️",$2 "°"}' +