Show your i3-wm configs/scripts

Just to share configuration tricks and hints for i3-wm:
Show your config for i3-wm or just a script used for the panel, or a nice panel to use, e.t.c. simply share it here!

  1. link to the script/config or adding it (if short) in code tags
  2. tutorial on how to use and install
  3. share a screenshot
4 Likes

entries for i3-blocks:

[newslink]
full_text=
command=firefox http://www.tagesschau.de/xml/rss2
color=#7f7fff

[feed]
command=rsstail -N -u http://www.tagesschau.de/xml/rss2  
#command=rsstail -n1 -1 -N -u http://www.tagesschau.de/xml/rss2
interval=persist

install rsstail:
yay -S rsstail
https://python-rsstail.readthedocs.io/en/latest/

  • find a feed to use, what must be compatible with rss2
  • clicking on the icon will open firefox with the full output
  • the feed text will show the top feed of that list as a short title output.

2020-11-26_19-05

3 Likes

As I understand it i3wm starts all exec with default /bin/sh.
To properly start an application in terminal window:

set $termshell alacritty -e bash -ic
bindsym $mod+F3 exec $termshell 'ranger'
bindsym $mod+n exec --no-startup-id $termshell 'nmtui'

Bash -i flag is there because I have [[ $- != *i* ]] && return at the beginning of my .bashrc file to ignore it if bash is not run interactively.

Also there is a bunch of XF86 keys that could be used if you have them on your keyboard.

XF86
bindsym XF86HomePage exec firefox
bindsym XF86Mail exec thunderbird
bindsym XF86Calculator exec speedcrunch
bindsym XF86Explorer exec $termshell 'ranger'
bindsym XF86MonBrightnessUp exec "xbacklight -inc 10; notify-send 'brightness up'"
bindsym XF86MonBrightnessDown exec "xbacklight -dec 10; notify-send 'brightness down'"
bindsym XF86AudioMute exec --no-startup-id "pactl set-sink-mute @DEFAULT_SINK@ toggle"
bindsym XF86AudioLowerVolume exec --no-startup-id "pactl set-sink-volume @DEFAULT_SINK@ -10% "
bindsym XF86AudioRaiseVolume exec --no-startup-id "pactl set-sink-volume @DEFAULT_SINK@ +10% "
5 Likes

A shutdown operation. I can’t remember where I took it from but it works without a flaw. :slightly_smiling_face:
So, $mod+Shift+q first and then s to shutdown my computer. No need to navigate mouse to i3-nagbar or instal additional power management software which takes place in an info-bar. Also it works even when polybar crashes down.

# Set shut down, restart and locking features
bindsym $mod+Shift+q mode "$mode_system"
set $mode_system (r)eboot, (s)hutdown, (L)ogout, (S)uspend
mode "$mode_system" {{
    bindsym r exec --no-startup-id systemctl reboot, mode "default"
    bindsym s exec --no-startup-id systemctl poweroff, mode "default"
    bindsym Shift+l exec --no-startup-id i3-msg exit, mode "default"
    bindsym Shift+s exec --no-startup-id systemctl suspend, mode "default"

    # exit system mode: "Enter" or "Escape"
    bindsym Return      mode "default"
    bindsym KP_Enter    mode "default"
    bindsym Escape      mode "default"
}}
1 Like

cmus now playing in bar (not know who write it ) i just got work on polybar

2020-11-27_13-44


#!/bin/bash

prepend_zero () {
        seq -f "%02g" $1 $1
}

artist=$(echo -n $(cmus-remote -C status | grep "tag artist" | cut -c 12-))

if [[ $artist = *[!\ ]* ]]; then
        song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-))
        position=$(cmus-remote -C status | grep position | cut -c 10-)
        minutes1=$(prepend_zero $(($position / 60)))
        seconds1=$(prepend_zero $(($position % 60)))
        duration=$(cmus-remote -C status | grep duration | cut -c 10-)
        minutes2=$(prepend_zero $(($duration / 60)))
        seconds2=$(prepend_zero $(($duration % 60)))
        echo -n "  >   $song   < By >   $artist   [ $minutes1:$seconds1  /  $minutes2:$seconds2 ]"
else
        echo
fi

Example for Polybar…

[module/cmus]
type = custom/script

exec = ~/.config/polybar/cmus.sh
exec-if = pgrep -x cmus
interval = 1

;click-left = cmus-remote --next
;click-right = cmus-remote --prev
;click-middle = cmus-remote --pause
;scroll-up = cmus-remote --volume +5%
;scroll-down = cmus-remote --volume -5%

label-font = 10
format-prefix =  Now Playing
format =      <label>
format-prefix-foreground = #807fff
label-foreground = #ffffff
;format-underline = #87004b
format-background = #99120f13
;format-underline = ${colors.foreground-alt}
label = %output%
label-maxlen = 100

uncomment click+scroll and that work from the bar

2 Likes

i3blocks… list of interesting blocks

6 Likes

Still trying to sort a way to get certain applications to be omitted from picom. Cromium is easy, firefox and steam not so much.

Currently playing with this. It will kill picom and then launch steam. I just havent figured out how to make a similar “button” to turn picom back on again.
i3 blocks

[Steam]
full_text= 
color=#ffffff
command=pkill picom && steam

i3-blocks it is :wink:

What do you want to ommit? If it is opacity you can use something like this in picom.conf:

click here to show
opacity-rule = [
    "95:class_g = 'URxvt' && _NET_WM_STATE@:32a *= 'NET_WM_STATE_FOCUSED'",
    "100:name *?= 'Conky'",
#    "50:class_g = 'Dmenu'",
    "100:name *?= 'smplayer'",
    "100:class_g= 'Gimp'",
#    "100:name *?= 'Screenshot'",
    "100:class_g = 'VirtualBox'",
    "100:name *?= 'VLC'",
    "50:class_g = 'Dunst'",
    "80:class_g = 'Thunar' && !_NET_WM_STATE@:32a *= '_NET_WM_STATE_FOCUSED'",
    "95:name *?= 'firefox' && !_NET_WM_STATE@:32a *= '_NET_WM_STATE_FOCUSED'"
#    "100:class_g = 'URxvt' && !_NET_WM_STATE@:32a",
#    "0:_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'",
#    "100:_NET_WM_STATE@:32a *= '_NET_WM_STATE_STICKY'"
];

If you want to get rid of edge shadows:

click here to show
shadow-exclude = [
    "! name~=''",
    "name = 'Notification'",
    "name = 'Plank'",
    "name = 'Docky'",
    "name = 'Kupfer'",
    "name = 'xfce4-notifyd'",
    "name = 'cpt_frame_window'",
    "name *= 'VLC'",
    "name *= 'compton'",
    "name *= 'picom'",
    "name *= 'Chromium'",
    "name *= 'Chrome'",
    "class_g ?= 'polybar'",
    "class_g = 'Firefox' && argb",
    "class_g = 'smplayer'",
    "class_g = 'Conky'",
    "class_g ?= 'Dmenu'",
	"class_g ?= 'Dunst'",
    "class_g = 'Kupfer'",
    "class_g = 'Synapse'",
    "class_g ?= 'Notify-osd'",
    "class_g ?= 'Cairo-dock'",
    "class_g ?= 'Xfce4-notifyd'",
    "class_g ?= 'Xfce4-power-manager'",
    "class_g ?= 'i3-frame'",
    "_GTK_FRAME_EXTENTS@:c",
    "_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'"
];

Also, to your example you could probably use

command="pkill picom && steam; picom -b"

command after ; will run no matter the exit state of steam. If picom is already running the new instance of picom -b will just exit with an error code that another instace was detected (don’t know how it behaves without -b argument). You have to kill steam to start picom this way. So, I am not exactly sure about your intentions

I think issue is that you do not want any transparency on games from outside the GAme itself, I am not sure, but disable the compositor can also cause lags on Gaming maybe?

What am I trying to do?:

I enjoy using transparency and blur with i3. The issue is picom alters the transparency globally. Which is fine for thunar, xed, xfce4-terminal ,etc. It is not great when watching youtube videos and or running games.The idea is to either:
A. Have a rule to have picom ignore the browser and steam. Which it looks like @vlkon has generously pointed me in a good direction. I had made an opacity rule for chromium and that works fine. Firefox is a differnt story but agin it looks like @vlkon has that covered above. Thats the part i couldn’t figure out.<—noob to i3.
B. Just have those apps (firefox and steam) kill the compositor when they launch and have a way to start the compositor again after they are exited.
Thank you! @joekamprad and @vlkon I now have something to work on tonight.

Edit actually not quite there yet.

Oh and @joekamprad the compositor often times actually gets in the way of games.

Those picom rules are nasty. You can test your application with xprop command (at least for X11). It will change your mouse cursor, then click on a window that you want to analyze and you will get a summary that you can use for a picom filter. For example:

~ >>> xprop
WM_HINTS(WM_HINTS):
_NET_WM_DESKTOP(CARDINAL) = 0
_NET_WM_STATE(ATOM) =
WM_STATE(WM_STATE):
		window state: Normal
		icon window: 0x0
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, _NET_WM_PING
_NET_WM_ICON(CARDINAL) =
WM_NORMAL_HINTS(WM_SIZE_HINTS):
		program specified size: 800 by 600
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
WM_CLIENT_MACHINE(STRING) = *redacted*
_NET_WM_PID(CARDINAL) = 14318
WM_CLASS(STRING) = "Alacritty", "Alacritty"
XdndAware(ATOM) = BITMAP
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x1, 0x0, 0x0
_NET_WM_NAME(UTF8_STRING) = "Alacritty"
WM_NAME(STRING) = "Alacritty"

There are more to these configs but I am no expert to give you a clear guide how to set it. I just set it by trial/error approach.

Edit: One more thing. The names of applications are case sensitive. So a rule 100:class_g = 'alacritty' will not work but 100:class_g = 'Alacritty' will work.

3 Likes

Xprop great tool and useful :+1: use it daily

2 Likes

Spoke too soon didn’t stand up the reboot. Back to researching lol.

1 Like

I just found this little gem.
It will process xprop/xwininfo output into one simple line that is useful for window identificaiton.

example
~ >>> i3-get-window-criteria
[class="Alacritty" id=20971522 instance="Alacritty" title="Alacritty"]
~ >>>
~ >>> i3-get-window-criteria
[class="feh" id=75497473 instance="feh" title="feh [2 of 6] - Dark Plasma 2 NoLogo.png"]
~ >>>

It can be then used for i3 config

for_window [class="feh"] floating enable

or in picom for example

"98:class_g = 'Alacritty' && _NET_WM_STATE@:32a *= 'NET_WM_STATE_FOCUSED'"
3 Likes
for_window [title="float"]  floating enable, resize set 1280 600, move position center, focus
for_window [title="floating"]  floating enable, resize set 720 400, move position center, focus

bindsym $mod1+t exec --no-startup-id "xfce4-terminal --title floating"

bindsym $mod1+r exec --no-startup-id "xfce4-terminal --title float -e ranger"

bindsym $mod1+h exec --no-startup-id "xfce4-terminal --title float -e htop"
bindsym $mod+Ctrl+Up exec mpc volume +2

bindsym $mod+Ctrl+Down exec mpc volume -2

bindsym $mod+Ctrl+Left exec mpc prev

bindsym $mod+Ctrl+Right exec mpc next

bindsym $mod+Ctrl+d exec mpc del 0
2 Likes

very close to what i use for cmus . my little different like for toggle play/pause

bindsym Ctrl+Down

Thank you for useful share . i sure it help many people :pray:

1 Like

i find them useful too
you can change number

for_window [workspace=$ws1] layout tabbed
for_window [workspace=$ws2] layout tabbed
for_window [workspace=$ws3] layout tabbed

opens in tabbed layout
in workspace 1,2,3

there are much you can with i3wm

#switch to next or previous workspace
# switch to next or previous workspace
bindsym $mod+Mod1+Left workspace prev
bindsym $mod+Mod1+Right workspace next

#change gaps

# change gaps
bindsym $Mod+plus                gaps inner current plus  5
bindsym $Mod+minus               gaps inner current minus 5

#Resize

# Size
bindsym Mod1+Up    resize shrink height 10 px or 10 ppt
bindsym Mod1+Down  resize grow   height 10 px or 10 ppt
bindsym Mod1+Left  resize shrink width  10 px or 10 ppt
bindsym Mod1+Right resize grow   width  10 px or 10 ppt
2 Likes

it no perfect + other do more but it perfect for my need. few minute then you up& running ! little config no long time wasted make thing work

2 Likes

if it covers your needs then it is perfect :slightly_smiling_face:
that’s the fun of wm
you can set it up to whatever you feel like
PS. I’m not good at English :crazy_face:

2 Likes