分類
Linux 软件

Linux上的離線字典——GoldenDict

GoldenDict是一款方便的字典應用,不僅支持離線字典和屏幕取詞,也支持在線辭典服務。Fedora直接從軟件倉庫安裝 goldendict 即可sudo dnf install goldendict,默認的屏幕取詞快捷鍵是Ctrl+C+C。

分享幾個字典的下載地址:https://1drv.ms/f/s!AiSujQyFSc-uab_ItF61BBKnLUs。GoldenDict中的字典順序也是下面順序。

  1. Babylon_English_Chinese_S_.BGL
  2. Babylon_Chinese_S_English.BGL
  3. Oxford_Advanced_Learner_English-Chinese_Dictionary-4th.bgl
  4. ConciseOxfordEnglishDictionary.dsl.dz
  5. Oxford English Dictionary (2nd Edition) .bgl
  6. 现代汉英词典(金山).dsl.dz

安卓也有GoldenDict可用,我用的免費版(谷歌市場:GoldenDict Free),有最大5個字典的限制,但是也夠用了。

使用 espeak 來發音

#安裝espeak
sudo dnf install espeak
#打開GoldenDict,菜單欄依次選擇
#編輯/字典/字典來源/程式/新增
#新增內容為:
#類型:音訊
#名稱:espeak
#命令列:/usr/bin/espeak -v en -s 120 %GDWORD%
#圖示:/usr/share/doc/espeak/html/images/lips.png
#最後勾選啟用框,保存並重啟GoldenDict就可以有英文發音了

##如果要聽法語發音,
##只需要把命令列中的 en 換成 fr 即可。

更多字典可以從這些地方獲得:http://download.huzheng.org/(來自:Good offline dictionaries for GoldenDict)

使用 Speech Dispatcher 來發音

來到 2023 年,Speech Dispatcher 是新的語音生成器。這裏記錄下在 Fedora 上安裝以及命令調用的方法:

#安裝
sudo dnf install speech-dispatcher speech-dispatcher-utils
#使用
spd-say hello

本文更新於 2023/08/12。

分類
软件

youtube-dl

Edit 221015: 如果遇到一些 youtube-dl 不支持的網址,可以嘗試用 yt-dlp,來下載,比如 arte.tv 的視頻。可以用傳統的 pip 安裝:pip install yt-dlp也可以直接允許可執行文件。使用方法類似 youtube-dl。

之前用過一些在線提取和轉換YouTube視頻的服務,近來發現這些提取或轉換的鏈接要求ip一致,那就無法用洋蔥網絡下載了。好在發現youtube-dl這麼個好工具,不僅能下載單集視頻還能下載視頻列表;不僅能單獨下載字幕還能把字幕合入視頻,非常強大。目前用的這幾個參數,記錄一下。

#安裝youtube-dl
sudo dnf install youtube-dl
##單個視頻下載
#查看可下載的視頻,注意audio only的視頻,沒有伴音的哦
youtube-dl https://www.youtube.com/watch?v=qU52CFGTGu0 -F
#下載編號為22的視頻
youtube-dl --proxy socks5://127.0.0.1:9150 qU52CFGTGu0 -f 22
#續傳中斷的視頻
youtube-dl --proxy socks5://127.0.0.1:9150 qU52CFGTGu0 -f 22 --continue
#列出所有字幕
youtube-dl --proxy socks5://127.0.0.1:9150 qU52CFGTGu0 --list-subs
#只下載字幕而不下載視頻
youtube-dl --all-subs --skip-download --proxy socks5://127.0.0.1:9150 https://www.youtube.com/watch?v=qU52CFGTGu0
#使用aria2搭配proxychains實現多進程下載
sudo dnf install aria2 proxychains-ng
proxychains4 youtube-dl -f mp4 --external-downloader aria2c --external-downloader-args '-c -j4 -x 4 -s 4 -k 5M' lW0ugxbtIEE
##視頻列表下載
#將視頻列表中的視頻連接輸出到文本文件
youtube-dl -j --flat-playlist "https://www.youtube.com/playlist?list=PLATwx1z00HsdanKZcTMQEc-n_Bhu_aZ76" | jq -r '.id' | sed 's_^_https://youtu.be/_' > list.log
#從文件里讀取視頻地址並下載,下載過的會保存於done.txt不會重複下載
youtube-dl -f mp4 --external-downloader aria2c --external-downloader-args '-c -j5 -x 5 -s 5 -k 10M --max-download-limit 1024k' --batch-file list.log --download-archive done.txt

#下載分辨率是 1080 的最佳畫質音視頻
yt-dlp --format "bv*[height=1080]+ba/b" qU52CFGTGu0
#舊電視或機頂盒可能不支持 VP90 視頻編碼以及 opus 音頻編碼
#或者不識別默認的 webm 視頻文件,這時可以選擇較舊的 avc1(h264) 視頻編碼和 mp4a 音頻編碼來解決
yt-dlp qU52CFGTGu0 -F
yt-dlp qU52CFGTGu0 -f 137+140

參考:youtube-dl批量下载时,跳过之前已经下载过的文件

Using yt-dlp in command line網頁存檔

本文更新於 2024/09/20。

分類
Linux

Hourly Reminder

忙起來的時候不知不覺時間就過去了,而久坐對健康絕對不是什麼好事。那麼就產生了一個需求,提醒我時間的流逝。Android上有個不錯的開源應用Hourly Reminder,但是我是在工作的時候才需要提醒,所以最好是桌面彈窗。簡單搜索發現Fedora預裝的notify-send命令就能很好的實現toast效果,搭配crontab就能滿足需求了。

crontab -e
#單行Hourly Reminder簡潔版
0 9-18 * * 1-5 notify-send -t 6000 '整點咯' 'It is ? time.'
#Hourly Reminder python 豪華版
0 9-18 * * 1-5 /home/42/Programs/p37/bin/python /home/42/eclipse-workspace/scriptsP37/hourlyReminder.py

file:/home/42/eclipse-workspace/scriptsP37/hourlyReminder.py

#!/home/42/Programs/p37/bin/python
import time,datetime,subprocess,random

ts = int(time.time())
hour = datetime.datetime.fromtimestamp(ts).strftime('%H')
title = "現在時刻"+hour+"點整"
emojiList=['?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','☕️','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?']
content = '\r        '+random.choice(emojiList)+'\r'
subprocess.check_call(['notify-send','-t','6000',title,content])

定時任務參考自crontab guru。 Emoji複製自Get Emoji

代碼里的emoji被wordpress強制轉義,從段落里複製吧emojiList=['?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','☕️','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?']

本文更新於 2021/09/13。

分類
软件

Fedora使用Impactor安裝ipa

使用Impactor可以為蘋果手機安裝ipa程序,無論手機是否越獄。從Cydia Impactor下載需要的包並解壓。

./Impactor

./Impactor: error while loading shared libraries: libudev.so.0: cannot open shared object file: No such file or directory
#若出現上述錯誤則
sudo ln -sf /usr/lib64/libudev.so.1 /usr/lib64/libudev.so.0

./Impactor: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory
#若出現上述錯誤則
sudo dnf install libatomic

./Impactor: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
#若出現上述錯誤則
sudo dnf install ncurses-compat-libs

啟動Impactor後,先選中手機,再在Device>Install package選擇要安裝的包,輸入蘋果賬號密碼即可。




Fedora找尋丟失庫的方法,如

./Impactor: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
sudo dnf provides libncurses.so.5
ncurses-compat-libs-6.0-8.20170212.fc26.i686 : Ncurses compatibility libraries
軟體庫    :fedora
符合之來源:
Provide    : libncurses.so.5
sudo dnf install ncurses-compat-libs
分類
說說

棄用ibus-rime

試圖在Fedora26上使用Rime輸入法,經過數小時嘗試都不能完整打出自己想要的句子,只能吐血半升後放棄。IBus Intelligent Pinyin雖然有不少缺點也傻傻的,但仍然是我目前遇到最好用的開源拼音輸入法。查看源碼發現已經智能拼音已經更新到了1.10.92,在Fedora26上嘗試編譯失敗後(一天內兩次失敗,真是受打擊?),決定升級Fedora。

迅速新裝了一個Fedora 29 Xfce,很好用,美滋滋。

分類
程序

幹掉QQProtect.exe

本文使用python3搭配windows的定時任務來實現正常使用TIM而不運行QQProtect.exe的功能。之所以沒有用bat是因為bat會彈出黑色命令行窗口,而使用pythonw則不會彈窗,體驗較好。方法參考自知乎如何禁用QPCore service启动项?

#file:killQQP.pyw
#杀死QQProtect.exe:killQQP.pyw 1
#启动TIM时杀死QQProtect.exe:killQQP.pyw 2

import os,time,sys

def killProgress(targetProgress):
    if targetProgress in os.popen('tasklist /FI \"IMAGENAME eq '+targetProgress+'\"').read():
        os.system('TASKKILL /F /IM '+targetProgress)

progressToBeKill = "QQProtect.exe"
progressToBeLaunch = "TIM.exe"
targetProgressFile = 'E:\\\"Program Files (x86)\"\\Tencent\\TIM\Bin\\QQScLauncher.exe' 
  
if str(sys.argv[1]) == "1":
    killProgress(progressToBeKill)
elif str(sys.argv[1]) == "2":
    count = 0
    time.sleep(5)
    os.system(targetProgressFile)
    time.sleep(2)
    while count < 5:
        killProgress(progressToBeKill)
        time.sleep(10)
        count = count + 1
        
else:
    killProgress(progressToBeKill)

然後在開始菜單運行taskschd.msc,新建定時任務。第一個定時任務:常規選項卡勾選“使用最高權限運行”;觸發器選項卡選擇“登錄時”;操作選項卡,程序或腳本填pythonw的位置,比如我的是C:\Users\42\AppData\Local\Programs\Python\Python35\pythonw.exe,添加參數則填寫上面腳本所在位置加參數,如E:\code\killQQP.pyw 1,保存。第二個定時任務:常規選項卡勾選“使用最高權限運行”;觸發器選項卡選擇“發生事件時”,然後日誌選“應用程序”,源填入QPCore,時間ID填入0;操作選項卡,程序或腳本填pythonw的位置,我的還是C:\Users\42\AppData\Local\Programs\Python\Python35\pythonw.exe,添加參數填寫腳本所在位置加參數,如E:\code\killQQP.pyw 2,保存即可。QQ用戶需要修改targetProgressFile為QQ的啟動文件,可以通過在QQ啟動快捷方式上右鍵查看詳情取得。

附:啟動TIM時幹掉QQProtect.exe的定時任務的導出文件killQQP2.xml。

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2018-11-05T11:11:00.0447223</Date>
    <Author>42-PC\42</Author>
  </RegistrationInfo>
  <Triggers>
    <EventTrigger>
      <Enabled>true</Enabled>
      <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Application"&gt;&lt;Select Path="Application"&gt;*[System[Provider[@Name='QPCore'] and EventID=0]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
    </EventTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>42-PC\42</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\Users\42\AppData\Local\Programs\Python\Python35\pythonw.exe</Command>
      <Arguments>E:\code\killQQP.pyw 2</Arguments>
    </Exec>
  </Actions>
</Task>

本文更新於 2018/11/16。

分類
說說

18103113

Suddenly, they find that they can't take a picture without a camera.