瀏覽代碼

Add Screensaver Start/End Scripts

Things like suspending heavy applications and updating status in
Homeassistant
master
Nate Bohman 4 年之前
父節點
當前提交
36dcc58e7f
簽署人: Nate Bohman <natrinicle@gmail.com> GPG 金鑰 ID: C10546A54ABA1CE5
共有 2 個檔案被更改,包括 19 行新增0 行删除
  1. +3
    -0
      desktop/screensaver_end.sh
  2. +16
    -0
      desktop/screensaver_start.sh

+ 3
- 0
desktop/screensaver_end.sh 查看文件

@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ps -e -o stat,command,pid | grep '^T' | grep -P "(firefox|atom)" | awk '{print $NF}' | xargs -P0 -I {} kill -CONT {}

+ 16
- 0
desktop/screensaver_start.sh 查看文件

@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# MPRIS = Media Player Remote Interfacing Specification
firefox_mpris_dbus=$(dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep -Po "org.mpris.*firefox[^\"]+")

if [ -n ${firefox_mpris_dbus} ]; then
playback_string=$(dbus-send --print-reply --dest=${firefox_mpris_dbus} /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus' | grep -Po "(?<=string \")[^\"]+")
fi

# Suspend Firefox processes if not playing media
if [ -z "${playback_string}" ] || [ "${playback_string}" != "Playing" ]; then
ps aux | grep [f]irefox/[f]irefox | awk '{print $2}' | xargs -P0 -I {} kill -STOP {}
fi

# Suspend Atom processes
ps aux | grep "/[a]tom" | awk '{print $2}' | xargs -P0 -I {} kill -STOP {}

Loading…
取消
儲存