Linux Desktop (MATE) において ワンクリックでアプリケーションを起動させたいとき、カスタム・アプリケーションのランチャをパネルに追加します。
そのソフトが CUI のソフトのときは キーの型を[端末内で機能する]とするのですが、それを起動するときタスクバーに表示されるタイトルが単に[端末]となってしまい、何が実行されているのか分かりづらいです。
Windows の bat ファイルでは title コマンドを使って 実行されているウインドウのタイトルを簡単に変更できるのですが、同様のことを Linux で実現する方法を探しました。
Windows 起動時のスタートアップ処理として、ネットワークドライブにドライブレターを割り付けるバッチファイル (中身は net use コマンドなど) を呼び出しているのですが、思いのほかネットワーク接続の確立に時間がかかり、動作に失敗してしまうことがあります。バッチファイルから呼び出す形で、ネットワーク接続が安定するまで次のコマンドの実行を遅延させるプログラムを書きました。
' Copyright 2023 FUKUDA Satomi (https://satomichan.jp/)
'
' Licensed under the Apache License, Version 2.0 (the “License”);
' you may not use this file except in compliance with the License.
' You may obtain a copy of the License at
' http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing, software
' distributed under the License is distributed on an “AS IS” BASIS,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
'
' See the License for the specific language governing permissions and
' limitations under the License.
Public Module WaitNet
Public Function Main(args As String()) As Integer
'コマンドライン引数
If args.Length <> 4 Then
Console.WriteLine("USAGE: waitnet <host> <port> <timeout(sec)> <retry(num of times)>")
Console.WriteLine()
Console.WriteLine("ex) waitnet.exe www.nhk.or.jp 80 2 3")
Return 255
End If
Dim host As String = args(0)
Dim port As Integer = Integer.parse(args(1))
Dim timeout As Integer = Integer.parse(args(2))
Dim retry As Integer = Integer.parse(args(3))
Dim tcp As New System.Net.Sockets.TcpClient
' 接続
Dim IsConnectSuccess As Boolean
Do
IsConnectSuccess = true
Try
Dim task = tcp.ConnectAsync(host, port)
If Not task.wait(timeout * 1000) Then
IsConnectSuccess = false
End If
Catch ex As System.Exception
IsConnectSuccess = false
End Try
If IsConnectSuccess Then Exit Do
If retry = 0 Then Exit Do
Console.WriteLine("ReTry: More " & retry & " times To Go.")
retry = retry - 1
System.Threading.Thread.Sleep(5000)
Loop While retry >= 0
' 結果
Console.WriteLine("IsConnectSuccess: " & IsConnectSuccess)
If IsConnectSuccess Then
Return 0
Else
Return 1
End If
End Function
End Module
>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\vbc.exe waitnet.vb
Microsoft (R) Visual Basic Compiler version 14.8.9037
for Visual Basic 2012
Copyright (c) Microsoft Corporation. All rights reserved.
This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to Visual Basic 2012, which is no longer the latest version. For compilers that support newer versions of the Visual Basic programming language, see http://go.microsoft.com/fwlink/?LinkID=533241
>