ThinkPad T480sを購入して、Debian Stretchをインストールして使っています。

ウインドウマネージャーはi3wmを使っているのですが、色々と設定して少しづつ形になってきたので、今までやってきたことをメモしておく。

随時更新する予定です。

更新

2019-01-09

Backportsの設定を更新しました。

ThinkPad特有の問題(/etc/default/grub)

ThinkPad T480s だけではないようですが、XF86MonBrightnessUpXF86MonBrightnessDownなどのキーが、認識しないようです。

ググると、以下のように設定すればよい、とかいてあるので試したら無事設定できた。

参考リンク

設定

vimで開く。

sudo vim /etc/default/grub

以下のquiet

GRUB_CMDLINE_LINUX_DEFAULT="quiet"

quiet splash thinkpad-acpi.brightness_enable=1 acpi_backlight=vendorと変更する。

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash thinkpad-acpi.brightness_enable=1 acpi_backlight=vendor"

updateする。

sudo update-grub

最終的には、以下のような感じになった。

/etc/default/grub

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash thinkpad-acpi.brightness_enable=1 acpi_backlight=vendor"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

Backportsの設定(/etc/apt/sources.list.d/stretch-backports.list)

参考リンク

設定

オフィシャルの内容の通りに設定する。

/etc/apt/sources.list.d/stretch-backports.list

deb http://ftp.debian.org/debian stretch-backports main contrib non-free

更新(2019-01-09)

Twitterで「ftp.debian.orgではなくftp.jp.debian.orgがいいですよ。」と教えて頂いたので、修正しました。

/etc/apt/sources.list.d/stretch-backports.list

deb http://ftp.jp.debian.org/debian stretch-backports main contrib non-free

SDカードのマウント(/etc/fstab)

参考リンク

設定

DebianのWikiの通りに設定する。

/etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p2 during installation
UUID=e6ff3dca-fab9-4a9f-b515-da2c54b2031d /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=DD05-11E9  /boot/efi       vfat    umask=0077      0       1
# swap was on /dev/nvme0n1p3 during installation
UUID=139e15f9-b78b-4418-a25c-169a9f694db2 none            swap    sw              0       0
# / was on /dev/sda1 during installation
UUID=fa0490b7-b591-4538-aa36-a02e0883b609 /media/sdcard               ext4    errors=remount-ro 0       1

トラックポイントとタッチパットの設定(/usr/share/X11/xorg.conf.d/30-touchpad.conf)

参考リンク

設定

作る。

/usr/share/X11/xorg.conf.d/30-touchpad.conf

Section "InputClass"
  Identifier "trackpoint catchall"
  Driver "libinput"
  MatchIsPointer "true"
  MatchProduct "Elantech Touchpad|TrackPoint"
  MatchDevicePath "/dev/input/event*"
  Option "NaturalScrolling" "true"
EndSection

Section "InputClass"
  Identifier "touchpad catchall"
  Driver "libinput"
  MatchIsTouchpad "true"
  MatchProduct "Elantech Touchpad|TrackPoint"
  MatchDevicePath "/dev/input/event*"
  Option "Tapping" "on"
  Option "NaturalScrolling" "true"
EndSection

xinputを使って設定

xinputコマンドでも設定できる。

例として、TouchpadのNaturalScrollingを設定する。

(cmd) ~ $ xinput
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ ETPS/2 Elantech Touchpad                  id=11   [slave  pointer  (2)]
⎜   ↳ ETPS/2 Elantech TrackPoint                id=12   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Sleep Button                              id=8    [slave  keyboard (3)]
    ↳ Integrated Camera                         id=9    [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=10   [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                    id=13   [slave  keyboard (3)]
    ↳ 08:EB:ED:9C:C4:FF                         id=14   [slave  keyboard (3)]

(cmd) ~ $ xinput list-props 11
Device 'ETPS/2 Elantech Touchpad':
        Device Enabled (139):   1
        Coordinate Transformation Matrix (141): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        libinput Tapping Enabled (274): 1
        libinput Tapping Enabled Default (275): 0
        libinput Tapping Drag Enabled (276):    1
        libinput Tapping Drag Enabled Default (277):    1
        libinput Tapping Drag Lock Enabled (278):       0
        libinput Tapping Drag Lock Enabled Default (279):       0
        libinput Tapping Button Mapping Enabled (280):  1, 0
        libinput Tapping Button Mapping Default (281):  1, 0
        libinput Accel Speed (282):     0.000000
        libinput Accel Speed Default (283):     0.000000
        libinput Natural Scrolling Enabled (284):       1
        libinput Natural Scrolling Enabled Default (285):       0
        libinput Send Events Modes Available (259):     1, 1
        libinput Send Events Mode Enabled (260):        0, 0
        libinput Send Events Mode Enabled Default (261):        0, 0
        libinput Left Handed Enabled (286):     0
        libinput Left Handed Enabled Default (287):     0
        libinput Scroll Methods Available (288):        1, 1, 0
        libinput Scroll Method Enabled (289):   1, 0, 0
        libinput Scroll Method Enabled Default (290):   1, 0, 0
        libinput Click Methods Available (291): 1, 1
        libinput Click Method Enabled (292):    1, 0
        libinput Click Method Enabled Default (293):    1, 0
        libinput Middle Emulation Enabled (294):        0
        libinput Middle Emulation Enabled Default (295):        0
        libinput Disable While Typing Enabled (296):    1
        libinput Disable While Typing Enabled Default (297):    1
        Device Node (262):      "/dev/input/event2"
        Device Product ID (263):        2, 14
        libinput Drag Lock Buttons (298):       <no items>
        libinput Horizontal Scroll Enabled (299):       1

(cmd) ~ $ xinput set-prop 11 "libinput Natural Scrolling Enabled" 0

xbacklightでエラーになるため設定(/usr/share/X11/xorg.conf.d/20-intel.conf)

以下のようなコマンドを実行するとno outputs have backlight propertiesとでるので、設定する。

(cmd) ~ $ xbacklight -inc 5
(cmd) ~ $ xbacklight -dec 5

参考リンク

設定

作る。

/usr/share/X11/xorg.conf.d/20-intel.conf

Section "Device"
  Identifier  "Backlight fix"
  Driver      "intel"
  Option      "Backlight"  "intel_backlight"
EndSection

fcitxを使う設定(~/.inputrc)

im-configで、自動で作成されるみたい。

~/.inputrc

# im-config(8) generated on Fri, 21 Dec 2018 21:56:16 +0900
run_im fcitx
# im-config signature: a0820a046c134d6459275e7ce49f57a2  -

rofiやdmenu_runにシェルスクリプトを追加する設定(~/.Xsessionrc)

rofiやdmenu_runの中に自分で作成したシェルスクリプトを追加するために、作る。

.bashrc.profile$PATHとは別のようなので、設定する。

source $HOME/.bashrcなどでも良いと思う。

キーリピートの設定はお好みで。

~/.Xsessionrc

if [ -d "$HOME/bin" ] ; then
  PATH="$HOME/bin:$PATH"
fi

# key repeat
xset r rate 250 90

キーマップの設定(~/.Xmodmap)

参考リンク

設定

以下のようなキーマップに変更している。

CapsLock -> Control_L
Alt_R -> Super_R
Alt_L -> Control_L
Super_L -> Alt_L
Control_L -> Super_L

作る。

起動時に読み込まれる。

~/.Xmodmap

! -*- coding: utf-8 -*-
! 2019-01-01

! swap Ctrl and Alt keys

! output taken from:
! xmodmap -pke | egrep '(Control|Super|Alt|Menu)'
! Use to set keycodes correctly below. List reordered to match
! keys from left to right.

! keycode  37 = Control_L NoSymbol Control_L
! keycode  64 = Alt_L Meta_L Alt_L Meta_L
! keycode  66 = CapsLock
! keycode 105 = Control_R NoSymbol Control_R
! keycode 108 = Alt_R Meta_R Alt_R Meta_R
! keycode 133 = Super_L NoSymbol Super_L
! keycode 134 = Super_R NoSymbol Super_R
! keycode 135 = Menu

! First clear all modifiers, caps lock & control
clear lock
clear control
clear mod1
clear mod4

keycode  37 = Super_L NoSymbol Super_L
keycode  64 = Control_L NoSymbol Control_L
keycode  66 = Control_L NoSymbol Control_L
keycode 105 = Control_R NoSymbol Control_R
keycode 108 = Super_R NoSymbol Super_R
keycode 133 = Alt_L Meta_L Alt_L Meta_L
keycode 134 = Alt_R Meta_R Alt_R Meta_R

! We need to set keycodes first, as some programs (emacs!) read
! the key names and seem to ignore what's below.
add mod1    = Alt_R Alt_L Meta_R Meta_L
add mod4    = Super_R Super_L Menu
add control = Control_R Control_L

i3wmの設定(~/.config/i3/config)

i3lock.shなどは、.Xsessionrcでパスを通している。

~/.config/i3/config

# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#

# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!

set $mod Mod4

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
#font pango:monospace 8
font pango:Ricty Diminished Regular 11

# 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

# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesn’t scale on retina/hidpi displays.

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# start a terminal
bindsym $mod+Return exec gnome-terminal

# kill focused window
bindsym $mod+Shift+q kill

# start dmenu (a program launcher)
bindsym $mod+d exec --no-startup-id ~/bin/i3rofi.sh
bindsym control+space exec --no-startup-id ~/bin/i3rofi.sh

# 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

# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l 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+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l 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

# switch to workspace
bindsym $mod+1 workspace 1
bindsym $mod+2 workspace 2
bindsym $mod+3 workspace 3
bindsym $mod+4 workspace 4
bindsym $mod+5 workspace 5
bindsym $mod+6 workspace 6
bindsym $mod+7 workspace 7
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9
bindsym $mod+0 workspace 10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace 1
bindsym $mod+Shift+2 move container to workspace 2
bindsym $mod+Shift+3 move container to workspace 3
bindsym $mod+Shift+4 move container to workspace 4
bindsym $mod+Shift+5 move container to workspace 5
bindsym $mod+Shift+6 move container to workspace 6
bindsym $mod+Shift+7 move container to workspace 7
bindsym $mod+Shift+8 move container to workspace 8
bindsym $mod+Shift+9 move container to workspace 9
bindsym $mod+Shift+0 move container to workspace 10

# 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'"

# Screen brightness controls
bindsym XF86MonBrightnessUp exec xbacklight -inc 5
bindsym XF86MonBrightnessDown exec xbacklight -dec 5

# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id i3audio.sh up #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id i3audio.sh down #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id i3audio.sh toggle # mute sound

# print
bindsym Print exec --no-startup-id kazam

# Sleep key
#bindsym XF86Sleep exec --no-startup-id systemctl suspend

# 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 h resize shrink width 10 px or 10 ppt
        bindsym j resize grow height 10 px or 10 ppt
        bindsym k resize shrink height 10 px or 10 ppt
        bindsym l 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"

# move floating windows with keys
mode "move" {
    bindsym $mod+Tab focus right

    bindsym Left  move left
    bindsym Down  move down
    bindsym Up    move up
    bindsym Right move right

    bindsym h     move left
    bindsym j     move down
    bindsym k     move up
    bindsym l     move right

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+m mode "move" focus floating

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
        status_command i3status
        font pango:Ricty Diminished Regular 12
        position    top
        tray_output primary
        tray_padding -2
}

# all kill
# Close all windows on all workspaces (any class string)
#bindsym $mod+Shift+q [class=”.*”] kill

# title bar
new_window none
new_float none
for_window [class="^.*"] border none

# lock
bindsym Control+Shift+l exec --no-startup-id i3lock.sh

# for key bind emacs
exec --no-startup-id gnome-settings-daemon

# display
exec --no-startup-id ~/.screenlayout/2048x1152.sh

# wallpaper
exec --no-startup-id feh --bg-scale /home/teruhiro/.config/i3/images/1920x1080_FullHD_v2.jpg

# autolock
exec --no-startup-id xautolock -detectsleep -time 5 -locker i3lock.sh

i3statusの設定(~/.config/i3status/config)

nmcliでネットワークを確認する。

(cmd) ~ $ nmcli
docker0: connected to docker0
        bridge, 02:42:DD:C0:DB:BF, sw, mtu 1500
        inet4 172.17.0.1/16

wlp61s0: connected to z5j5zb82ds-network-5GHz 6
        "Intel Sunrise Point-LP PCI Express Root Port"
        wifi (iwlwifi), 98:3B:8F:B3:61:04, hw
        ip4 default
        inet4 192.168.100.3/24
        route4 169.254.0.0/16
        inet6 fe80::e647:cb7:436e:a0d2/64

enp0s31f6: unavailable
        "Intel Ethernet Connection (4) I219-V"
        ethernet (e1000e), E8:6A:64:6C:05:E1, hw, mtu 1500

vmnet1: unmanaged
        ethernet (unknown), 00:50:56:C0:00:01, hw, mtu 1500

vmnet8: unmanaged
        ethernet (unknown), 00:50:56:C0:00:08, hw, mtu 1500

lo: unmanaged
        loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536

DNS configuration:
        servers: 192.168.100.1
        interface: wlp61s0

Use "nmcli device show" to get complete information about known devices and
"nmcli connection show" to get an overview on active connection profiles.

Consult nmcli(1) and nmcli-examples(5) manual pages for complete usage details.

(もしくは)ipでネットワークを確認する。

(ins) ~ $ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s31f6: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
    link/ether e8:6a:64:6c:05:e1 brd ff:ff:ff:ff:ff:ff
3: wlp61s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
    link/ether 98:3b:8f:b3:61:04 brd ff:ff:ff:ff:ff:ff
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default
    link/ether 02:42:dd:c0:db:bf brd ff:ff:ff:ff:ff:ff
5: vmnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 00:50:56:c0:00:01 brd ff:ff:ff:ff:ff:ff
6: vmnet8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 00:50:56:c0:00:08 brd ff:ff:ff:ff:ff:ff

設定

上で調べたネットワークを指定する。

~/.config/i3status/config

general {
        output_format = "i3bar"
        #output_format = "dzen2"
        colors = true
        color_good =     '#88b090'
        color_degraded = '#ccdc90'
        color_bad =      '#e89393'
        interval = 5
        separator = "  "
}

#order += "ipv6"
order += "disk /"
order += "run_watch DHCP"
#order += "run_watch VPNC"
#order += "path_exists VPN"
order += "wireless wlp61s0"
order += "ethernet enp0s31f6"
order += "battery 0"
#order += "cpu_temperature 0"
order += "load"
order += "tztime local"
#order += "tztime berlin"

wireless wlp61s0 {
        #format_up = "W: (%quality at %essid, %bitrate) %ip"
        format_up = "W: (%quality at %essid) %ip"
        format_down = "W: down"
}

ethernet enp0s31f6 {
        # if you use %speed, i3status requires the cap_net_admin capability
        format_up = "E: %ip (%speed)"
        format_down = "E: down"
}

battery 0 {
        #format = "%status %percentage %remaining %emptytime"
        format = "%status %percentage %remaining"
        format_down = "No battery"
        status_chr = "⚡ CHR"
        status_bat = "🔋 BAT"
        status_unk = "? UNK"
        status_full = "☻ FULL"
        path = "/sys/class/power_supply/BAT%d/uevent"
        low_threshold = 10
}

run_watch DHCP {
        pidfile = "/var/run/dhclient*.pid"
}

run_watch VPNC {
        # file containing the PID of a vpnc process
        pidfile = "/var/run/vpnc/pid"
}

path_exists VPN {
        # path exists when a VPN tunnel launched by nmcli/nm-applet is active
        path = "/proc/sys/net/ipv4/conf/tun0"
}

tztime local {
        format = "%Y-%m-%d %H:%M:%S"
}

tztime berlin {
        format = "%Y-%m-%d %H:%M:%S %Z"
        timezone = "Europe/Berlin"
}

load {
        format = "%5min"
}

cpu_temperature 0 {
        format = "T: %degrees °C"
        path = "/sys/devices/platform/coretemp.0/temp1_input"
}

disk "/" {
        format = "%free"
}

オーディオ関連の設定(~/bin/i3audio.sh)

最初は、pasystrayを使っていましたが、接続のたびにアイコンを操作するのがつかれるので、シェルスクリプトを作った。

まずはpacmdの使い方を覚える

sinkの一覧を表示する。

以下の例では、3つ接続している状態。

  • Built-in Audio Analog Stereo
  • Soundcore Liberty Air
  • Pixel USB-C earbuds Analog Stereo

ちなみに、Soundcore Liberty Airに接続している。

(cmd) ~ $ pacmd list-sinks
3 sink(s) available.
    index: 0
	name: <alsa_output.pci-0000_00_1f.3.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY FLAT_VOLUME DYNAMIC_LATENCY
	state: SUSPENDED
	suspend cause: IDLE 
	priority: 9959
	volume: front-left: 3242 /   5% / -78.34 dB,   front-right: 3242 /   5% / -78.34 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 0
	sample spec: s16le 2ch 48000Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	configured latency: 0.00 ms; range is 0.50 .. 1837.50 ms
	card: 0 <alsa_card.pci-0000_00_1f.3>
	module: 6
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "ALC257 Analog"
		alsa.id = "ALC257 Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "HDA Intel PCH"
		alsa.long_card_name = "HDA Intel PCH at 0xe8348000 irq 145"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1f.3"
		sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "9d71"
		device.form_factor = "internal"
		device.string = "front:0"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "Built-in Audio Analog Stereo"
		alsa.mixer_name = "Realtek ALC257"
		alsa.components = "HDA:10ec0257,17aa2258,00100001 HDA:8086280b,80860101,00100000"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-speakers"
		analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-headphones"
	active port: <analog-output-speaker>
  * index: 3
	name: <bluez_sink.08_EB_ED_9C_C4_FF.a2dp_sink>
	driver: <module-bluez5-device.c>
	flags: HARDWARE DECIBEL_VOLUME LATENCY FLAT_VOLUME 
	state: RUNNING
	suspend cause: 
	priority: 9430
	volume: front-left: 13062 /  20% / -42.03 dB,   front-right: 13062 /  20% / -42.03 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 30.12 ms
	max request: 2 KiB
	max rewind: 0 KiB
	monitor source: 4
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 1
	linked by: 1
	fixed latency: 39.51 ms
	card: 3 <bluez_card.08_EB_ED_9C_C4_FF>
	module: 25
	properties:
		bluetooth.protocol = "a2dp_sink"
		device.description = "Soundcore Liberty Air"
		device.string = "08:EB:ED:9C:C4:FF"
		device.api = "bluez"
		device.class = "sound"
		device.bus = "bluetooth"
		device.form_factor = "headphone"
		bluez.path = "/org/bluez/hci0/dev_08_EB_ED_9C_C4_FF"
		bluez.class = "0x240418"
		bluez.alias = "Soundcore Liberty Air"
		device.icon_name = "audio-headphones-bluetooth"
	ports:
		headphone-output: Headphone (priority 0, latency offset 0 usec, available: yes)
			properties:
				
	active port: <headphone-output>
    index: 4
	name: <alsa_output.usb-Google_Pixel_USB-C_earbuds_00000087QAJ52920-00.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY FLAT_VOLUME DYNAMIC_LATENCY
	state: SUSPENDED
	suspend cause: IDLE 
	priority: 9049
	volume: front-left: 19656 /  30% / -31.38 dB,   front-right: 19656 /  30% / -31.38 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 5
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	configured latency: 0.00 ms; range is 0.50 .. 2000.00 ms
	card: 4 <alsa_card.usb-Google_Pixel_USB-C_earbuds_00000087QAJ52920-00>
	module: 26
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "USB Audio"
		alsa.id = "USB Audio"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "1"
		alsa.card_name = "Pixel USB-C earbuds"
		alsa.long_card_name = "Google Pixel USB-C earbuds at usb-0000:3c:00.0-1, full speed"
		alsa.driver_name = "snd_usb_audio"
		device.bus_path = "pci-0000:3c:00.0-usb-0:1:1.0"
		sysfs.path = "/devices/pci0000:00/0000:00:1c.4/0000:04:00.0/0000:05:02.0/0000:3c:00.0/usb3/3-1/3-1:1.0/sound/card1"
		udev.id = "usb-Google_Pixel_USB-C_earbuds_00000087QAJ52920-00"
		device.bus = "usb"
		device.vendor.id = "18d1"
		device.vendor.name = "Google Inc."
		device.product.id = "5033"
		device.product.name = "Pixel USB-C earbuds"
		device.serial = "Google_Pixel_USB-C_earbuds_00000087QAJ52920"
		device.string = "front:1"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "Pixel USB-C earbuds Analog Stereo"
		alsa.mixer_name = "USB Mixer"
		alsa.components = "USB18d1:5033"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-usb"
	ports:
		analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-headphones"
	active port: <analog-output-headphones>

Pixel USB-C earbuds Analog Stereoを使うために、indexを設定する。

(ins) ~ $ pacmd set-default-sink 4

これで、Soundcore Liberty AirからPixel USB-C earbuds Analog Stereoに切り替わる。

以下のようにすれば、音量の変更や、ミュートにできる。

(ins) ~ $ pactl set-sink-volume 4 +5%
(ins) ~ $ pactl set-sink-volume 4 -5%
(ins) ~ $ pactl set-sink-mute 4 toggle

シェルスクリプトを作った

~/bin/i3audio.sh


#!/usr/bin/env bash
set -Ceuo pipefail

TARGET="$1"

AUDIOPATH="/var/tmp/i3audio.txt"

# check param
if [ x$TARGET = "x" ]; then
  exit 1
fi

# check audio index
if [ -f "$AUDIOPATH" ]; then
  # exists
  INDEX=$(cat "$AUDIOPATH")
else
  # not exists
  echo -n "0" > "$AUDIOPATH"
  INDEX="0"
fi

# set index
if [ $TARGET = "index" ]; then
  # echo pacmd list-sinks
  CNT=0
  pacmd list-sinks | while read LINE
  do
    CNT=$(expr $CNT + 1)
    if [ "`echo $LINE | grep -e 'index:'`" ]; then
      echo "$LINE"
    elif [ "`echo $LINE | grep -e 'state:' -e 'volume:' -e 'device.description ='`" ]; then
      echo "   $LINE"
    fi
  done
  # read index number
  while :
  do
    read -p "Input index number (number or c=cancel): " DATA
    # check input number
    if [ "$DATA" = "c" ]; then
      echo "Canceled."
      break
    else
      expr "$DATA" + 1 > /dev/null 2>&1
      if [ $? -lt 2 ]; then
        # is Numeric
        echo -n "$DATA" >| "$AUDIOPATH"
        pacmd set-default-sink "$DATA"
        echo "Done."
        break
      else
        # is not Numeric
        break
      fi
    fi
  done
fi

# volume up
if [ $TARGET = "up" ]; then
  pactl set-sink-volume $INDEX +5%
fi

# volume down
if [ $TARGET = "down" ]; then
  pactl set-sink-volume $INDEX -5%
fi

# volume toggle
if [ $TARGET = "toggle" ]; then
  pactl set-sink-mute $INDEX toggle
fi

シェルスクリプトの使い方

簡単なので、説明は不要だと思いますが、いちおう…

var/tmp/i3audio.txtにindexを記録するようにしているだけです。

i3audio.sh indexと実行すると、indexとdeviceを表示するので、数字を入力すればよい。という感じです。

どうやら@DEFAULT_SINK@なるものがあるようなのですが、うまいこと機能しなかったので作りました。

(cmd) ~ $ cat /var/tmp/i3audio.txt
3
(ins) ~ $ i3audio.sh index
index: 0
   state: SUSPENDED
   volume: front-left: 3242 /   5% / -78.34 dB,   front-right: 3242 /   5% / -78.34 dB
   base volume: 65536 / 100% / 0.00 dB
   device.description = "Built-in Audio Analog Stereo"
* index: 3
   state: RUNNING
   volume: front-left: 13062 /  20% / -42.03 dB,   front-right: 13062 /  20% / -42.03 dB
   base volume: 65536 / 100% / 0.00 dB
   device.description = "Soundcore Liberty Air"
index: 4
   state: SUSPENDED
   volume: front-left: 19656 /  30% / -31.38 dB,   front-right: 19656 /  30% / -31.38 dB
   base volume: 65536 / 100% / 0.00 dB
   device.description = "Pixel USB-C earbuds Analog Stereo"
Input index number (number or c=cancel): 4
Done.
(cmd) ~ $ cat /var/tmp/i3audio.txt
4

参考リンク

@DEFAULT_SINK@の例

bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10%
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10%
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle

Bluetoothの設定(bluetoothctl)

最初はbluemanを使っていましたが、現在はbluetoothctlを使っています。

(ins) ~ $ bluetoothctl
[NEW] Controller 98:3B:8F:B3:61:08 debian [default]
[NEW] Device 08:EB:ED:9C:C4:FF Soundcore Liberty Air

(ins) [Soundcore Liberty Air]# disconnect
Attempting to disconnect from 08:EB:ED:9C:C4:FF
[CHG] Device 08:EB:ED:9C:C4:FF ServicesResolved: no
Successful disconnected
[CHG] Device 08:EB:ED:9C:C4:FF Connected: no

(ins) [bluetooth]# connect 08:EB:ED:9C:C4:FF
Attempting to connect to 08:EB:ED:9C:C4:FF
[CHG] Device 08:EB:ED:9C:C4:FF Connected: yes
Connection successful
[CHG] Device 08:EB:ED:9C:C4:FF ServicesResolved: yes

(ins) [Soundcore Liberty Air]#
(ins) [bluetooth]# help
Available commands:
  list                       List available controllers
  show [ctrl]                Controller information
  select <ctrl>              Select default controller
  devices                    List available devices
  paired-devices             List paired devices
  power <on/off>             Set controller power
  pairable <on/off>          Set controller pairable mode
  discoverable <on/off>      Set controller discoverable mode
  agent <on/off/capability>  Enable/disable agent with given capability
  default-agent              Set agent as the default one
  advertise <on/off/type>    Enable/disable advertising with given type
  set-advertise-uuids [uuid1 uuid2 ...] Set advertise uuids
  set-advertise-service [uuid][data=[xx xx ...] Set advertise service data
  set-advertise-manufacturer [id][data=[xx xx ...] Set advertise manufacturer data
  set-advertise-tx-power <on/off> Enable/disable TX power to be advertised
  set-scan-filter-uuids [uuid1 uuid2 ...] Set scan filter uuids
  set-scan-filter-rssi [rssi] Set scan filter rssi, and clears pathloss
  set-scan-filter-pathloss [pathloss] Set scan filter pathloss, and clears rssi
  set-scan-filter-transport [transport] Set scan filter transport
  set-scan-filter-clear      Clears discovery filter.
  scan <on/off>              Scan for devices
  info [dev]                 Device information
  pair [dev]                 Pair with device
  trust [dev]                Trust device
  untrust [dev]              Untrust device
  block [dev]                Block device
  unblock [dev]              Unblock device
  remove <dev>               Remove device
  connect <dev>              Connect device
  disconnect [dev]           Disconnect device
  list-attributes [dev]      List attributes
  set-alias <alias>          Set device alias
  select-attribute <attribute> Select attribute
  attribute-info [attribute] Select attribute
  read                       Read attribute value
  write <data=[xx xx ...]>   Write attribute value
  notify <on/off>            Notify attribute value
  register-profile <UUID ...> Register profile to connect
  unregister-profile         Unregister profile
  version                    Display version
  quit                       Quit program

ネットワークの設定(nmcli)

最初はnm-appletを使っていましたが、現在はnmcliを使っています。

(cmd) ~ $ nmcli device wifi list
*  SSID                     MODE   CHAN  RATE       SIGNAL  BARS  SECURITY
   z5j5zb82ds-network       Infra  6     54 Mbit/s  82      ▂▄▆█  WPA2
*  z5j5zb82ds-network-5GHz  Infra  100   54 Mbit/s  60      ▂▄▆_  WPA2
   AirPort23728             Infra  5     54 Mbit/s  59      ▂▄▆_  WPA1 WPA2
   Game23728                Infra  5     54 Mbit/s  59      ▂▄▆_  WEP
   wx03-0d7465              Infra  6     54 Mbit/s  54      ▂▄__  WPA1 WPA2
   FS030W_P25856            Infra  11    54 Mbit/s  52      ▂▄__  WPA2
   pwr-q9526fa-1            Infra  6     54 Mbit/s  45      ▂▄__  WPA2
   0024A5D76337-1           Infra  6     54 Mbit/s  42      ▂▄__  WPA1
   --                       Infra  6     54 Mbit/s  42      ▂▄__  WEP
   2400BACA560A-2G          Infra  8     54 Mbit/s  42      ▂▄__  WPA1 WPA2
   Buffalo-G-AD78           Infra  6     54 Mbit/s  37      ▂▄__  WPA1 WPA2
   2400BACA560A-5G          Infra  116   54 Mbit/s  35      ▂▄__  WPA1 WPA2
   HUMAX-7FF3C-A            Infra  136   54 Mbit/s  35      ▂▄__  WPA1 WPA2
   HUMAX-34C66              Infra  1     54 Mbit/s  34      ▂▄__  WPA1 WPA2
   pr500m-aa1e02-2          Infra  11    54 Mbit/s  34      ▂▄__  WPA2
   pr500m-aa1e02-1          Infra  11    54 Mbit/s  30      ▂___  WPA2
   HUMAX-7FF3C              Infra  1     54 Mbit/s  29      ▂___  WPA1 WPA2
   aterm-9de1e8-g           Infra  1     54 Mbit/s  29      ▂___  WPA1 WPA2
   Buffalo-G-DB48           Infra  11    54 Mbit/s  29      ▂___  WPA1 WPA2
   Extender-G-7258          Infra  11    54 Mbit/s  29      ▂___  WPA2
(ins) ~ $ nmcli device wifi connect
--                       2400BACA560A-5G          Buffalo-G-AD78           FS030W_P25856            HUMAX-7FF3C              pr500m-aa1e02-2          z5j5zb82ds-network
0024A5D76337-1           AirPort23728             Buffalo-G-DB48           Game23728                HUMAX-7FF3C-A            pwr-q9526fa-1            z5j5zb82ds-network-5GHz
2400BACA560A-2G          aterm-9de1e8-g           Extender-G-7258          HUMAX-34C66              pr500m-aa1e02-1          wx03-0d7465

(ins) ~ $ nmcli device wifi connect z5 <-タブで補完される
z5j5zb82ds-network       z5j5zb82ds-network-5GHz

(ins) ~ $ nmcli device wifi connect z5j5zb82ds-network password HOGE
Device 'wlp61s0' successfully activated with '8e11011c-11a1-4446-be23-13a6a19acb6b'.
(ins) ~ $ nmcli help
Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }

OPTIONS
  -t[erse]                                   terse output
  -p[retty]                                  pretty output
  -m[ode] tabular|multiline                  output mode
  -c[olors] auto|yes|no                      whether to use colors in output
  -f[ields] <field1,field2,...>|all|common   specify fields to output
  -e[scape] yes|no                           escape columns separators in values
  -a[sk]                                     ask for missing parameters
  -s[how-secrets]                            allow displaying passwords
  -w[ait] <seconds>                          set timeout waiting for finishing operations
  -v[ersion]                                 show program version
  -h[elp]                                    print this help

OBJECT
  g[eneral]       NetworkManager's general status and operations
  n[etworking]    overall networking control
  r[adio]         NetworkManager radio switches
  c[onnection]    NetworkManager's connections
  d[evice]        devices managed by NetworkManager
  a[gent]         NetworkManager secret agent or polkit agent
  m[onitor]       monitor NetworkManager changes

i3lock(~/bin/i3lock.sh)

~/bin/i3lock.sh

#!/bin/sh
i3lock -e -i ~/.config/i3/images/background.png

-e オプションはお好みで。

 -e, --ignore-empty-password
        When an empty password is provided by the user, do not validate it. Without this option, the empty password will be provided to PAM and, if invalid, the user will have to wait a few  seconds  before  another
        try. This can be useful if the XF86ScreenSaver key is used to put a laptop to sleep and bounce on resume or if you happen to wake up your computer with the enter key.

キーマップの設定(~/bin/i3setxkb.sh)

最初は、これでやってたが.Xmodmapを使っているため、使わなくなった。

~/bin/i3setxkb.sh

#!/bin/sh
setxkbmap -option "caps:ctrl_modifier,ctrl:swap_lalt_lctl_lwin,terminate:ctrl_alt_bksp,altwin:swap_alt_win"

ディスプレイの設定(~/.screenlayout/2048x1152.sh)

arandrというコマンドがおすすめです。

GUIアプリで、マルチディスプレイの設定も比較的うまいことできます。

設定を保存すると、以下のようなシェルスクリプトが生成されます。

i3のconfigで、起動時に以下のシェルスクリプトを実行しています。

~/.screenlayout/2048x1152.sh

#!/bin/sh
xrandr --output VIRTUAL1 --off --output eDP1 --mode 2048x1152 --pos 0x0 --rotate normal --output DP1 --off --output HDMI2 --off --output HDMI1 --off --output DP2 --off

スクリーンショット、画面録画(kazam)

simplescreenrecorderが良いって記事を見るけど、個人的にはkazamの方が良いので、使っている。

sudo aptitude show kazam

aptのhistoryの場所

/var/log/apt/history.log
/var/log/apt/history.log.1.gz
/var/log/dpkg.log
/var/log/dpkg.log.1

インストールしたパッケージや使っているコマンドなど

  • go
  • fzf
  • vim
  • font(いろいろ)
  • vmware player
  • nodebrew
  • yarn
  • ternjs
  • JetBrains Toolbox
  • Sublime Text
  • VSCode
  • xsel
  • sheetskv(自分で作ったCLIツール)
  • oathtool
  • aptitude
  • Google Chrome
  • Firefox
  • KeePassXC
  • skicka
  • aws CLI
  • gcp CLI
  • i3status
  • i3lock
  • curl
  • httpie
  • lightdm
  • blueman(bluetoothctlコマンドを使っているので、使っていない)
  • nm-applet(nmcliコマンドを使っているので、使っていない)
  • pasystray(i3audio.shを使っているので、使っていない)
  • docker
  • zeal
  • dconf-editor
  • firmware-iwlwifi
  • feh
  • tig
  • trash-cli
  • tmux
  • parcellite
  • VirtulBox
  • gparted
  • cmake
  • ffmpeg
  • mps-youtube(cmusに移行したので、使っていない)
  • youtube-dl
  • weechat
  • simplescreenrecorder(kazamの方がよい)
  • tree
  • mplayer
  • strongswan
  • xl2tpd
  • xautolock
  • exuberant-ctags
  • kazam
  • vokoscreen
  • obs-studio
  • gtk-recordmydesktop
  • recordmydesktop
  • mutt
  • lightdm-gtk-greeter-settings
  • jq
  • cmus
  • xdotool
  • bluez-tools
  • screenfetch
  • rxvt-unicode-256color
  • xinput
  • libinput-tools
  • debian-keyring

あとがき

Debianもi3wmも、まだまだビギナーなので、これからも使っていきたい。