public_notes/content/20240318201835 ログインしたら自動的にDISPLAY変数を設定したい.md

13 lines
No EOL
531 B
Markdown

# 20240318201835 ログインしたら自動的にDISPLAY変数を設定したい
#tips #x-window
`~/.profile`などに、こんな感じで書いておく。
```sh
# auto set display to last login
export DISPLAY=`who -um | awk '{print $NF}'| sed s/[\(\)]//g`:0.0
```
## Ref.
- [Automatically set DISPLAY Variable ?](https://community.hpe.com/t5/operating-system-hp-ux/automatically-set-display-variable/td-p/3370014) 現在のlinuxだとIPに () が付いてしまうので、↑はそこを取るsedを追加してある。