Instal dan Atur i3 Windows Manager di Ubuntu 20.04

Selamat datang di tutorial kami tentang cara menginstal i3 windows manager di Ubuntu 20.04. i3 adalah pengelola jendela ubin untuk X11. “SEBUAH tiling window manager adalah pengelola jendela dengan pengaturan layar ke dalam bingkai yang tidak copyg tumpang tindih, berlawanan dengan pendekatan yang lebih populer dari penumpukan objek (jendela) yang tumpang tindih berbasis koordinat yang mencoba sepenuhnya meniru metafora desktop.”

Instal dan Atur i3 Windows Manager di Ubuntu 20.04

Jalankan Pembaruan Sistem

Untuk memulainya, jalankan pembaruan paket sistem.

apt update

Instal i3 di Ubuntu 20.04

i3 windows manager dapat diinstal melalui i3paket yang tersedia di repo default Ubuntu 20.04.

apt show i3
Package: i3 Version: 4.17.1-1 Priority: optional Section: universe/x11 Source: i3-wm Origin: Ubuntu Maintainer: Ubuntu Developers  Original-Maintainer: Michael Stapelberg  Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 20.5 kB Depends: i3-wm (= 4.17.1-1) Recommends: i3lock (>= 2.2), suckless-tools, i3status (>= 2.3), dunst Homepage: https://i3wm.org/ Download-Size: 1,996 B APT-Sources: http://ke.archive.ubuntu.com/ubuntu focal/universe amd64 Packages 

Ada alat lain yang diperlukan untuk menggunakan window manager i3 secara efisien. Ini termasuk;

  • i3 window manager: i3-wm itu sendiri
  • i3lock loker layar
  • i3status untuk informasi sistem
  • suckless-tools untuk dmenu

Paket-paket ini diinstal bersama dengan paket meta i3.

Instal i3 Windows Manager terbaru dari Ubuntu/Debian Repos

Versi stabil i3 saat ini adalah 4.18.2. Namun, jika Anda dapat memeriksa versi yang disediakan oleh repo default Ubuntu, Anda menyadari bahwa itu tidak mutakhir.

Untuk memastikan kami menginstal dan versi terbaru dan untuk memastikan pembaruan/peningkatan yang mulus, buat repo i3-wm;

wget -O- https://baltocdn.com/i3-window-manager/signing.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/i3wm-signing.gpg
apt install apt-transport-https --yes
echo "deb https://baltocdn.com/i3-window-manager/i3/i3-autobuild/ all main" | sudo tee /etc/apt/sources.list.d/i3-autobuild.list

Perbarui daftar sumber paket Anda.

apt update

Anda sekarang dapat menginstal i3-wm versi terbaru dengan menjalankan perintah di bawah ini;

apt install i3

Mengonfigurasi i3 Windows Manager di Ubuntu 20.04

Setelah instalasi selesai, Anda sekarang dapat melanjutkan untuk mengkonfigurasi i3-wm di Ubuntu 20.04.

Pertama, keluar dari sistem Anda dan masuk lagi. Saat masuk, pastikan untuk memilih sesi i3 sebagai layar masuk Anda.

Setelah berhasil masuk, Anda akan diminta untuk:

  • buat file konfigurasi i3-wm secara otomatis, ~/.config/i3/configatau
  • cukup gunakan file konfigurasi default.

Dalam pengaturan ini, kita akan menggunakan opsi pertama karena harus membuat file konfigurasi i3-wm secara otomatis. Nanti akan kita modifikasi sesuai dengan kebutuhan kita. Oleh karena itu, tekanENTER dan lanjutkan.

Selanjutnya, Anda perlu menentukan kunci pengubah i3-wm ($mod). Anda memiliki dua opsi di sini: Anda dapat menggunakan Windows logo keyatau Alt key. Dalam pengaturan ini, kita akan menggunakan kunci $mod yang populer,  Windows logo keysebagai pengubah i3-wm kita, dan dipilih secara default. Gunakan tombol panah atas atau bawah untuk memilih$mod kunci.

Tulis perubahan dengan menekan ENTER.

Dan Anda sekarang akan disambut oleh layar hitam dengan beberapa bilah status di bagian bawah yang menyerupai yang ditunjukkan pada gambar di bawah;

Penggunaan Dasar i3

Sekarang setelah diinstal dengan pengaturan konfigurasi dasar, ada beberapa kombinasi tombol yang dapat digunakan untuk melakukan beberapa tugas dasar;

Perhatikan bahwa $mod mewakili kunci pengubah yang Anda pilih. Kunci Alt atau Win.It is Win key on our setup.

  • Buka terminal: $mod + ENTER.
  • Meluncurkan aplikasi sistem melalui dmenu: $mod + d. Ini membuka menu di bagian atas layar tempat Anda dapat memasukkan kata kunci untuk mencari aplikasi tertentu.
  • Masuk dan matikan mode layar penuh: $mod + f.
  • Menutup jendela aplikasi; $mod + Shift + q
  • Memulai ulang i3: $mod + Shift + r.
  • Keluar dari pengelola jendela i3: $mod + Shift + e.

Menyesuaikan i3 di Ubuntu 20.04

Selanjutnya, kami ingin membuat i3 menarik dan mudah digunakan. Anda dapat menyesuaikan i3-wm dengan memodifikasi ~/.config/i3/configfile.

Di bawah ini adalah contoh konfigurasi i3 wm kami;

# Please see http://i3wm.org/docs/userguide.html for a complete reference! # set_from_resource $darkred color1 #000000 set_from_resource $red color9 #000000 set_from_resource $darkgreen color2 #000000 set_from_resource $green color10 #000000 set_from_resource $darkyellow color3 #000000 set_from_resource $yellow color11 #000000 set_from_resource $darkblue color4 #000000 set_from_resource $blue color12 #000000 set_from_resource $darkmagenta color5 #000000 set_from_resource $magenta color13 #000000 set_from_resource $darkcyan color6 #000000 set_from_resource $cyan color14 #000000 set_from_resource $darkwhite color7 #000000 set_from_resource $white color15 #000000 # Use custom colors for black set $black #282828 set $darkblack #1d2021 set $transparent #00000000 set $mod Mod4 set $mod1 Mod1 set $terminator terminator # 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 12 # 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 12 #font pango:Meslo LG L Regular Nerd Font Complete 15 # Use Mouse+$mod to drag floating windows to their wanted position floating_modifier $mod # start a terminator by pressing Mod key + x or ENTER bindsym $mod+Return exec $terminator bindsym $mod+x exec $terminator # Custom bindsyms bindsym $mod+p exec ~/.config/i3/bin/logout bindsym $mod+l exec i3lock -i /home/koromicha/Pictures/linuxtux.png bindsy
m $mod+c exec google-chrome bindsym $mod+r mode "resize" bindsym $mod+Shift+f exec /home/koromicha/.config/i3/bin/rofifinder # Enable Print Screen #bindsym --release $mod+Print exec gnome-screenshot -i bindsym --release $mod+Print exec shutter -s # kill focused window bindsym $mod+q kill # start dmenu (a program launcher) bindsym $mod+d exec --no-startup-id ~/.config/i3/bin/rofi_app_launcher # 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+t 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+z focus child # Workspace Variables set $ws1 "1: " #set $ws2 "2: " set $ws2 "2: " set $ws3 "3: " set $ws4 "4: " set $ws5 "5: " set $ws6 "6:" set $ws7 "7:" set $ws8 "8: " set $ws9 "9: " # 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 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 Up resize grow height 10 px or 10 ppt bindsym Down 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" } # # Pulse Audio controls # run pactl list sinks #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 1 toggle # mute sound # Amixer bindsym XF86AudioRaiseVolume exec --no-startup-id amixer -D pulse sset Master 5%+ #increase sound volume bindsym XF86AudioLowerVolume exec --no-startup-id amixer -D pulse sset Master 5%- #decrease sound volume# bindsym XF86AudioMute exec --no-startup-id amixer -q set Master toggle # mute sound # Sreen brightness controls # enable passwordless sudo for ybacklight. echo "koromicha ALL=NOPASSWD: /usr/bin/ybacklight" > /etc/sudoers.d/ybacklight bindsym XF86MonBrightnessUp exec sudo ybacklight -inc 5 # increase screen brightness bindsym XF86MonBrightnessDown exec sudo ybacklight -dec 5 # decrease screen brightness # i3blocks bar { status_command i3blocks position top font pango:Hack, FontAwesome 11 colors { separator #081419 background #253941 #statusline #839496 focused_workspace #fdf6e3 #6c71c4 #fdf6e3 active_workspace #fdf6e3 #6c71c4 #fdf6e3 inactive_workspace #002b36 #586e75 #002b36 urgent_workspace #d33682 #d33682 #fdf6e3 statusline $white separator $transparent } } set $m1 #808080 set $m2 #FFF0E0 # Startup programs exec --no-startup-id dunst exec_always compton &; exec --no-startup-id clipit &; exec_always feh --bg-scale /home/koromicha/Pictures/linux-wallpaper.jpg exec_always --no-startup-id nm-applet # Bind App to workspace # Check class by using xprop command assign [class="chromium"] $ws2 assign [class="Firefox"] $ws2 assign [class="Atom"] $ws3 assign [class="Foxit Reader"] $ws3 assign [class="Pcmanfm"] $ws4 assign [class="VirtualBox"] $ws5 assign [class="Virt-manager"] $ws5 assign [class="Skype"] $ws6 assign [class="mpv"] $ws9 assign [class="vlc"] $ws9 assign [class="Thunderbird"] $ws7 assign [class="(?i)libreoffice-startcenter"] $ws8 assign [class="(?i)soffice"] $ws8 assign [class="(?i)libreoffice"] $ws8 # Assign to certain workspace assign [window_role="browser"] $ws2 # Press $mod+o followed by either f, s, l, m, v, k, d, t, Esc or Return {ENTER), # to launch FoxiReader, Skype, lxappearance, thunderbird, VirtualBox, # KVM Virt-manager, spectacle, pcmanfm file manager, # or return to the default mode, respectively. set $mode_launcher Launcher bindsym $mod+o mode "$mode_launcher" mode "$mode_launcher" { bindsym f exec FoxitReader bindsym s exec skypeforlinux bindsym l exec lxappearance bindsym m exec thunderbird bindsym v exec VirtualBox bindsym k exec virt-manager bindsym d exec spectacle bindsym t exec "pcmanfm /home/koromicha" bindsym Esc mode "default" bindsym Return mode "default" } # Shutdown, Reboot, Lock Screen, and Logout set $power_mode "power" bindsym $mod+Shift+q mode $power_mode mode $power_mode { bindsym p exec systemctl poweroff bindsym r exec systemctl reboot bindsym l exec i3lock -i /home/koromicha/Pictures/linuxtux.png, mode "default" bindsym q exec --no-startup-id i3-msg exit, mode "default" bindsym h exec sudo systemctl hibernate bindsym s exec sudo systemctl suspend bindsym Return mode "default" bindsym Escape mode "default" } # Floating windows for_window [window_role="task_dialog|bubble|page-info|Preferences|pop-up"] floating enable for_window [window_role="Open Files"] floating enable sticky for_window [window_role="File Operation Progress"] floating enable sticky for_window [class="qBittorrent" window_role="pop-up"] floating enable for_window [window_type="dialog"] floating enable for_window [window_type="menu"] floating enable # Sticky window for_window [instance="file_progress"] sticky enable for_window [class="info|Mate-color-select|gcolor2|timesup|QtPass|GtkFileChooserDialog"] sticky enable # Focus window settings no_focus [window_role="pop-up"] focus_on_window_activation focus 

Konfigurasi di atas memberi kita jendela seperti itu;

Apa yang dibutuhkan untuk hal di atas?

Instal Membutuhkan paket

Sejumlah paket diperlukan untuk tampilan di atas dan berbagai shortcut yang ditentukan dalam file konfigurasi di atas;

apt install feh fonts-font-awesome rofi pulseaudio-utils xbacklight alsa-tools clipit gcc git terminator locate pcmanfm acpi libnotify-bin htop

Instal ybacklight untuk mengontrol kecerahan layar jika xbacklight tidak berfungsi;

git clone https://github.com/szekelyszilv/ybacklight.git cd ybacklight/src gcc ybacklight.c -o /usr/bin/ybacklight

Instal Rana untuk tangkapan layar;

sudo add-apt-repository -y -u ppa:linuxuprising/shutter apt install shutter

Instal Skrip Keluar i3

Seperti yang didefinisikan konfigurasi i3 di atas, skrip logout, yang memberikan interface logout seperti yang ditunjukkan di bawah ini saat menekan $mod+pkombinasi tombol, dipasang di bawah, ~/.config/i3/bin/logout.

Buat direktori skrip biner i3 dan instal skrip logout.

mkdir ~/.config/i3/bin/ vim ~/.config/i3/bin/logout
#!/usr/bin/env bash # Manage logout with rofi option=`echo -e "suspendnlock screennlogoutnrebootnpoweroffnKill user $USER" | rofi -width 600 -dmenu -p system:` case $option in suspend) sudo /usr/bin/systemctl syspend ;; 'lock screen') i3lock -i /home/koromicha/Pictures/linuxtux.png ;; logout) i3-nagbar -t warning -m 'Are you sure you want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit' ;; reboot) /usr/bin/systemctl reboot ;; poweroff) /usr/bin/systemctl poweroff ;; 'kill user $USER') loginctl kill-user $USER ;; esac 

NB: Script adalah versi modifikasi dari skrip logout yang disediakan di repositori github Jmutai dotfiles. Pastikan untuk membuat skrip dapat dieksekusi;

chmod +x ~/.config/i3/bin/logout

Cari dan Cari File menggunakan Rofi

Rofi dapat digunakan untuk mencari dan menemukan file dan folder di dalam sistem Anda. Di bawah ini adalah script rofi finder yang kami gunakan;

vim ~/.config/i3/bin/rofifinder
#!/bin/bash xdg-open "$(locate -i / | rofi -threads 0 -width 100 -dmenu -i -p "Find")"

Pencari rofi dapat diluncurkan, sesuai konfigurasi kami, dengan menekan $mod+Shift+fkombinasi tombol. Ini adalah tampilannya seperti;

Perhatikan bahwa skrip menggunakan locateperintah. Di sana instal, jika belum instal, dan perbarui database mlocate;

apt install mlocate && updatedb

Meluncurkan Aplikasi Sistem menggunakan Rofi

Anda juga dapat mengonfigurasi rofi untuk meluncurkan aplikasi sistem Anda dengan i3-dmenu-desktop. Di bawah ini adalah skrip yang digunakan dalam panduan ini untuk meluncurkan aplikasi sistem;

vim ~/.config/i3/bin/rofi_app_launcher
#!/usr/bin/env bash # Run rofi app launcher i3-dmenu-desktop --dmenu="rofi -dmenu -i -p 'apps'"
chmod +x ~/.config/i3/bin/rofi_app_launcher

Konfigurasi i3 untuk peluncur aplikasi rofi adalah;

# start dmenu (a program launcher) bindsym $mod+d exec --no-startup-id ~/.config/i3/bin/rofi_app_launcher

Pintasan untuk meluncurkan peluncur aplikasi rofi sesuai konfigurasi kami adalah, $mod+d. Lihat contoh layar menu peluncuran;

Untuk menyesuaikan jendela rofi, gunakan rofi-theme-selector.

Kustomisasi lainnya;

Aktifkan Layar Cetak menggunakan rana

# Enable Print Screen #bindsym --release $mod+Print exec gnome-screenshot -i bindsym --release $mod+Print exec shutter -s

Membunuh jendela terfokus;

# kill focused window bindsym $mod+q kill

Mengubah Fokus antara jendela yang berbeda di Ruang Kerja (lihat shortcut tombol masing-masing);

# 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 

Memisahkan Jendela secara vertikal ($mod+v) atau horizontal ($mod+h);

# split in horizontal orientation bindsym $mod+h split h # split in vertical orientation bindsym $mod+v split v

Atur jendela dalam mode layar penuh ($mod+f);

# enter fullscreen mode for the focused container bindsym $mod+f fullscreen toggle

Atur jendela ke mode ubin atau mengambang ($mod+Shift+space);

# toggle tiling / floating bindsym $mod+Shift+space floating toggle

Mengubah fokus jendela induk atau anak;

# focus the parent container bindsym $mod+a focus parent # focus the child container bindsym $mod+z focus child

Mengatur Ikon untuk Ruang Kerja yang berbeda;

# Workspace Variables set $ws1 "1: " #set $ws2 "2: " set $ws2 "2: " set $ws3 "3: " set $ws4 "4: " set $ws5 "5: " set $ws6 "6:" set $ws7 "7:" set $ws8 "8: " 

Perhatikan bahwa kami juga mengikat berbagai aplikasi ke ruang kerja masing-masing;

# Bind App to workspace # Check class by using xprop command assign [class="chromium"] $ws2 assign [class="Firefox"] $ws2 assign [class="Atom"] $ws3 assign [class="Foxit Reader"] $ws3 assign [class="Pcmanfm"] $ws4 assign [class="VirtualBox"] $ws5 assign [class="Virt-manager"] $ws5 assign [class="Skype"] $ws6 assign [class="mpv"] $ws9 assign [class="vlc"] $ws9 assign [class="Thunderbird"] $ws7 assign [class="(?i)libreoffice-startcenter"] $ws8 assign [class="(?i)soffice"] $ws8 assign [class="(?i)libreoffice"] $ws8
 # Assign to certain workspace assign [window_role="browser"] $ws2 
Setel Wallpaper i3

Pertama, mari kita atur wallpaper. wallpaper i3 dapat diatur menggunakan fehpenampil gambar yang ringan, dapat dikonfigurasi, dan serbaguna. Jalankan perintah di terminal.

feh --bg-scale /path/to/wallpaper.jpg

Ini akan secara otomatis mengubah wallpaper Anda. Untuk memastikan bahwa wallpaper selalu disetel saat Anda masuk ke sesi i3 Anda, edit file~/.config/i3/config dan atur jalur yang benar ke gambar wallpaper Anda;

exec_always feh --bg-scale /path/to/wallpaper.jpg

Konfigurasi i3blocks

i3blocks adalah alternatif untuk i3status. i3blocks tersedia di repo default Ubuntu 20.04. Instal i3blocks dan itu dengan menjalankan perintah di bawah ini;

apt install i3blocks

Selanjutnya, konfigurasikan i3 untuk menggunakan i3blocks alih-alih i3status dengan mengganti bagian i3 bar {}dengan konfigurasi di bawah ini;

# i3blocks bar { status_command i3blocks position top font pango:Hack, FontAwesome 11 colors { separator #081419 background #253941 #statusline #839496 focused_workspace #fdf6e3 #6c71c4 #fdf6e3 active_workspace #fdf6e3 #6c71c4 #fdf6e3 inactive_workspace #002b36 #586e75 #002b36 urgent_workspace #d33682 #d33682 #fdf6e3 statusline $white separator $transparent } } 

Ini harus mengubah bilah status i3. Anda juga membutuhkan blocklet i3blocks. “Bloklet adalah konfigurasi dari satu blok, bagian dari garis status”. Anda dapat menemukan daftar bloklet yang  lengkap di halaman bloklet. Dalam pengaturan saya, sebagian besar skrip diambil dari vivien blocklets.

Sebelum Anda dapat melanjutkan untuk mendapatkan skrip blocklets, edit i3blocks.conf untuk menentukan font ikon Anda. Ikon Font-Mengagumkan digunakan dalam panduan ini;

vim /etc/i3blocks.conf
# i3blocks config file # # Please see man i3blocks for a complete reference! # 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 # # top properties below are applied to every block, but can be overridden. # Each block command defaults to the script name to avoid boilerplate. command=~/.config/i3/blocklets/$BLOCK_NAME separator=false separator_block_width= 10 markup=pango align=right # RAM usage [memory] interval=1 label= color=#4CAF50 # CPU Usage [cpu_usage] label=  interval=2 color=#87AFAF # /home Partition Usage [disk-home] label=: interval=30 color=#586E75 # Network Interface IP [iface] color=#B4B7B4 interval=1 separator=false label=  # Wi-Fi SSID [ssid] label=  color=#d33682 interval=2 #Network Bandwidth [bandwidth] interval=1 color=#d33682 # Screen brightness [brightness] label=  interval=1 signal=2 color=#738899 # Battery level [battery] interval=10 # Date and Time Calendar [time] label=  interval=1 color=#50C878 # Battery level notification [batnotify] interval=10 separator_block_width=4 

Buat direktori untuk menyimpan skrip blocklets;

mkdir ~/.config/i3/blocklets

Beberapa blocklet yang digunakan dalam pengaturan ini adalah;

ls.config/i3/blocklets/ -1
bandwidth batnotify battery brightness cpu_usage disk-home iface memory ssid time

Di bawah ini adalah isi skrip;

Penggunaan RAM;

#!/bin/sh # Copyright (C) 2014 Julien Bonjean  # 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. TYPE="${BLOCK_INSTANCE:-mem}" awk -v type=$TYPE ' /^MemTotal:/ { 	mem_total=$2 } /^MemFree:/ { 	mem_free=$2 } /^Buffers:/ { 	mem_free+=$2 } /^Cached:/ { 	mem_free+=$2 } /^SwapTotal:/ { 	swap_total=$2 } /^SwapFree:/ { 	swap_free=$2 } END { 	if (type == "swap") { 		free=swap_free/1024/1024 		used=(swap_total-swap_free)/1024/1024 		total=swap_total/1024/1024 	} else { 		free=mem_free/1024/1024 		used=(mem_total-mem_free)/1024/1024 		total=mem_total/1024/1024 	} 	pct=used/total*100 	# full text 	printf("%.1fG/%.1fG (%.f%%)n", used, total, pct) 	# short text 	printf("%.f%%n", pct) 	# color 	if (pct > 90) { 		print("#FF0000n") 	} else if (pct > 80) { 		print("#FFAE00n") 	} else if (pct > 70) { 		print("#FFF600n") 	} } ' /proc/meminfo case $BLOCK_BUTTON in 1) termite -e htop ;; esac 

Skrip Penggunaan CPU;

#!/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 yellown"; print "-c : critical threshold to become redn"; 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 "#C75D50n"; exit 33; } elsif ($cpu_usage >= $t_warn) { print "#D7875Fn"; } exit 0; 

/home Penggunaan Partisi;

#!/bin/sh # Copyright (C) 2014 Julien Bonjean  # 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. DIR="${BLOCK_INSTANCE:-$HOME}" ALERT_LOW="${1:-10}" # color will turn red under this value (default: 10%) df -h -P -l "$DIR" | awk -v alert_low=$ALERT_LOW ' //.*/ { 	# full text 	print $4 	# short text 	print $4 	use=$5 	# no need to continue parsing 	exit 0 } END { 	gsub(/%$/,"",use) 	if (100 - use < alert_low) { 		# color 		print "#FF0000" 	} } ' # Mouse settings case $BLOCK_BUTTON in 1) i3-msg exec 'caja --browser' ;; # left click, locate +xdg-open files with rofi 3) i3-msg exec ~/.config/i3/bin/rofi_finder # find files on right click esac 

Rute default IP Interface Jaringan

#!/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 r
eceived 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 1) termite -e 'ping 8.8.8.8' ;; 3) echo -n "$IPADDR" | xclip -q -se c ;; esac #------------------------------------------------------------------------ echo "$IPADDR" # full text echo "$IPADDR" # short text 

SSID Wi-Fi;

#!/usr/bin/env bash # Be sure to change the WLAN interface echo "$(iw dev wlp0s20f3 link | grep SSID | cut -d " " -f 2-)"

Bandwidth Jaringan;

#!/bin/bash # 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 # # if the connection is down, the corresponding block should not be displayed. if ! [ -e "/sys/class/net/${INTERFACE}/operstate" ] || ! [ "`cat /sys/class/net/${INTERFACE}/operstate`" = "up" ] then 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 # outgoing tx_kib=$(( $tx_rate >> 10 )) if [[ "$tx_rate" -gt 1048576 ]]; then tx_mbs=$(printf '%s' "`echo "scale=1; $tx_kib / 1024" | bc`") echo -n "${tx_mbs}M↑." else echo -n "${tx_kib}K↑." fi # incoming rx_kib=$(( $rx_rate >> 10 )) if [[ "$rx_rate" -gt 1048576 ]]; then rx_mbs=$( printf '%s' "`echo "scale=1; $rx_kib / 1024" | bc`") echo -n "${rx_mbs}M↓" else echo -n "${rx_kib}K↓" fi # mouse buttons case $BLOCK_BUTTON in 1) tm-cli ;; # transmission-remote-cli 3) rofi-connm # rofi connection manager esac 

Status Baterai Sistem;

Periksa instance baterai dan ganti nilai x di BATx;

ls /sys/class/power_supply/
!/bin/sh # Copyright (C) 2014 Julien Bonjean  # 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. INSTANCE="${1:-BAT1}" ALERT_LOW="${2:-25}" # color will turn red under this value (default: 10%) UPOWER="/usr/bin/upower" if [ ! -x "$UPOWER" ]; then 	echo "upower not found" 	exit 1 fi $UPOWER -i /org/freedesktop/UPower/devices/battery_$INSTANCE | 	awk -v alert_low=$ALERT_LOW ' /state:/ { 	state = $2 } /time to full:/ { 	remaining_time = $4 " " substr ($5, 0, 1) } /time to empty:/ { 	remaining_time = $4 " " substr ($5, 0, 1) } /percentage:/ { 	percentage = $2; } END { 	if (state == "charging") label = "" 	else if (percentage == "100%") 		label = "" 	else if (percentage > 99) 		label = "" 	else if (percentage > 75) 		label = "" 	else if (percentage > 50) 		label = "" 	else if (percentage > 25) 		label = "" else if (percentage > 10) 		label = "" else if (percentage > 5) 		label = "" 	 # full text & "[email protected]" > /dev/null; print label " " percentage 	# short text 	print label " " percentage 	# color 	gsub(/%$/,"",percentage) if (percentage == "100") 		print "#c5c8c6" else if (state == "charging") 		print "#c5c8c6" else if (+ percentage < + alert_low) print "#cc6666" else if (percentage < 26) print "#af9f87" else print "#7ea3a3" } # mouse buttons case $BLOCK_BUTTON in 3) toggle-dpms ;; # left click, control DPMS 2) toggle-red ;; # right click, redshift on/off 1) getacpi ;; # dialog with battery info 5) sudo brightness up ;; # xbacklight doesn't work with modesetting use brightness script 4) sudo brightness down ;; esac 

Kalender Tanggal dan Waktu;

#!/bin/bash date_time=$(date '+%a %d-%m-%Y %R:%S') echo "$date_time" #Buttons Control case "$BLOCK_BUTTON" in 1) exec zenity --calendar ;; esac

Skrip Notifikasi Pengosongan Baterai. Pastikan untuk mengganti instance baterai, BATx yang sesuai.

#!/bin/bash # Battery notifier script for i3 # First warning is at 30%, Critical warning less than 15% discharge_mode=`acpi -a | grep -o off` # Get current battery level and set threshold battery_level=$(cat /sys/class/power_supply/BAT1/capacity) critical_value=15 warning_value=30 # Messages to print to notification message="*** Battery level is ${battery_level}%, critical, sleeping in 30 seconds time ***" warn_message="*** Battery level is ${battery_level}%, warning, connect your charger ***" # Notification icon to use not_icon="/usr/share/icons/gnome/scalable/status/battery-low-symbolic.svg" if [ "$discharge_mode" == "off" ]; then if [ "$battery_level" -le "$critical_value" ]; then if [ -f "$not_icon" ]; then notify-send -u critical -i "$not_icon" -t 60000 "$message" # i3-nagbar -m "$message" sleep 300 sudo /lib/systemd/systemd-sleep hybrid-sleep else notify-send -u critical -t 60000 "$message" #i3-nagbar -m "$message" sleep 120 sudo /lib/systemd/systemd-sleep hybrid-sleep fi elif [ "$battery_level" -eq "$warning_value" ]; then notify-send -u low -i "$not_icon" -t 60000 "$warn_message" fi fi 

Pastikan blocklet dapat dieksekusi;

chmod +x ~/.config/i3/blocklets/*

Beginilah tampilan bilah status i3 kami sekarang;

Dan itu cukup banyak di panduan kami tentang cara menginstal dan mengatur i3 windows manager di Ubuntu 20.04. Jangan ragu untuk menyesuaikan alat luar biasa ini sesuai keinginan Anda. Menikmati!!

Bacaan lebih lanjut

Lihat panduan user
i3 untuk referensi i3 yang komprehensif.

Panduan Pengguna i3

Tutorial lainnya

Instal dan Atur ZSH dan Oh-My-Zsh di Ubuntu 20.04

Instal Bitwarden Password Manager di Ubuntu 20.04

Pantau Koneksi OpenVPN dengan Prometheus dan Grafana

Instal dan Konfigurasi Server APT-Caching Menggunakan Apt-Cacher NG di Ubuntu 20.04