Ubuntuでいろいろ

・RDP

1.Ubuntuのインストール

2.Ubuntu側の設定

ターミナルからxrdpをインストール

sudo apt install xserver-xorg-core xorgxrdp xrdp

ターミナルでxrdpの設定

cat <<EOF > ~/.xsessionrc
export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_CURRENT_DESKTOP=ubuntu:GNOME
export XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share:/usr/share:/var/lib/snapd/desktop
export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
EOF

こっちも同様にターミナルで

sudo sed -e 's/^new_cursors=true/new_cursors=false/g' -i /etc/xrdp/xrdp.ini

cat <<EOF | \
sudo tee /etc/polkit-1/localauthority/50-local.d/xrdp-color-manager.pkla
[Netowrkmanager]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device
ResultAny=no
ResultInactive=no
ResultActive=yes
EOF

sudo systemctl restart xrdp
sudo systemctl restart polkit

最後にUbuntu機のIPアドレスを確認

ip -4 a

Ubuntuからログアウト

3.Windowsから接続

Win機からRDPと入力してリモートデスクトップ接続を起動
先ほど調べたIPアドレスを入力
ユーザー名とパスワードはUbuntuのものを入力

orenda.co.jp

Ubuntuでスクショ

スクリーンショットにはshutterを使用。aptでインストールする

$ sudo add-apt-repository ppa:linuxuprising/shutter
$ sudo apt install shutter

使い方はこんな感じ

shutter -e -n --disable_systray --window=.*XMTrading* -o '%y-%m-%d_%T.png'

window=で任意のウィンドウを指定する。-oオプションで名前を付けられる。

あとGoogleDriveにスクショを保存したかったのでマウントもした。

$ sudo add-apt-repository ppa:alessandro-strada/ppa
$ sudo apt-get update
$ sudo apt-get install google-drive-ocamlfuse

Googleアカウントの認証

google-drive-ocamlfuse

ブラウザが開くのでアカウントの認証とアクセスの許可をする。

最後にマウントしたいディレクトリを作ってマウント。

google-drive-ocamlfuse ~/GoogleDrive

なんかログアウトしたり再起動するとマウントが解除されてるので、アンマウントして再マウントとか何回かやってるとまたマウントできるようになる。

symfoware.blog.fc2.com
pineplanter.moo.jp

・Cronで定時実行

まずCronのインストール

sudo apt install -y cron

statusでCronの実行状態を見ることができる

sudo systemctl status cron

スケジュール設定はターミナルから設定できる

crontab -e

ここに設定を書き込む。設定例

0 0 * * 1-5 ~/dirauto.sh

先頭から分 時 日 月 曜日である。この例だと月曜から金曜(1-5)の0時0分にdirauto.shが実行される

*/30 * * * 1-5 DISPLAY=:10.0 ~/auto.sh

*/xのようにすることでxごとに実行されるようにもできる。
DISPLAY=っていうのでディスプレイを指定している。数字は「echo $DISPLAY」で調べられる。スクリーンショットするには必要だけど、つけなくても動くと思う。
あと、シェルスクリプトが動かないときはchmodで権限を付与してみると動くかもしれない。