자유게시판

조회 수 579 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

이전글: https://hamonikr.org/index.php?mid=board_bFBk25&document_srl=68978

 

이전에 i3에서 볼륨 조절 단축키 만드는 방법에 대한 글을 올린적이 있습니다.

이번에는 더 나아가서 dunst로 알람을 띄우는 방법을 알아보겠습니다.

 

참고로 전 pulseaudio를 사용하므로, pulseaudio를 사용한다는 가정하에 작성하겠습니다.

 

이전 스크립트는 이렇습니다.(1)


#!/bin/perl
use warnings;
use strict;
use v5.010;

$_ = qx/pacmd list-sinks/;
my ($sink, $vol) = /(?:^|\n)\h*\* index: (\S+).*?\n\h*volume:[^\n]*?(\d+)%/s;
if (scalar @ARGV == 1 and $ARGV[0] =~ /^ (-|\+)? (\d+)% | (toggle) $/x) {
    if ($3) {
        system "pactl set-sink-mute $sink toggle";
    } else {
        if (not $1) { $vol = $2; }
        elsif ($1 eq "-") { $vol -= $2; }
        elsif ($1 eq "+") { $vol += $2; }
        $vol = 0 if $vol < 0;
        $vol = 100 if $vol > 100;
        system "pactl set-sink-volume $sink $vol%";
    }
} else {
    my $name = $0 =~ s|.*/||r;
    print <<END;
Usage: $name [-|+]VOL% | toggle
Ex.:   $name 100%
       $name -5%
       $name +5%
       $name toggle   # mute/unmute
END
}

이 스크립트는 출력 장치를 따로 찾아서 수정할 필요가 없고,

볼륨이 mute라면 mute를 알아서 해제하고 볼륨을 조절합니다.

출처: https://www.reddit.com/r/linuxquestions/comments/94tdwz/pulseaudio_max_volume_limit/

 

여기서 더 나아가 볼륨을 조절할 때 마다 잠깐동안 알람을 띄우고 싶습니다.

우선 dunst를 설치합니다.

(물론 dunst말고 다른 프로그램을 사용할 수도 있을거 같습니다.

만약 그렇다면 아래 스크립트에서 dunstify를 수정해야겠네요)

그리고 다음 스크립트를 작성합니다.


#!/bin/bash

 

function get_volume {

pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,'

}

 

function is_mute {

pacmd list-sinks | grep mute | grep yes > /dev/null

}

 

function send_notification {

  iconSound="audio-volume-high"

  iconMuted="audio-volume-muted"

  if is_mute ; then

dunstify -i $iconMuted -r 2593 -u normal "mute"

  else

    volume=$(get_volume)

    # Make the bar with the special character ─ (it's not dash -)

    # https://en.wikipedia.org/wiki/Box-drawing_character

    bar=$(seq --separator="─" 0 "$((volume / 5))" | sed 's/[0-9]//g')

    # Send the notification

    dunstify -i $iconSound -r 2593 -u normal "    $bar"

  fi

}

 

case $1 in

    up)

1번 스크립트 경로 +5% > /dev/null

send_notification

;;

1번 스크립트 경로 -5% > /dev/null

send_notification

;;

    mute)

1번 스크립트 경로 toggle > /dev/null

send_notification

;;

esac


출처: https://gist.github.com/Blaradox/030f06d165a82583ae817ee954438f2e

 

send_notification 함수를 보면 아이콘이 지정되어 있습니다.

paper 아이콘 셋을 설치하고, dunstrc의 아이콘 경로에

usr/share/icons/Paper/16x16/status/ 와 /usr/share/icons/Paper/16x16/apps/ 를

추가해줘야 아이콘이 정상적으로 나옵니다.

추가하지 않아도 아이콘이 나오지 않는것 외에는 정상적으로 작동합니다.

 

사용 예시입니다.

2020-11-02-20:06:35-screenshot.png

오른쪽 위를 보면 알람이 정상적으로 작동하는 것을 확인할 수 있습니다.

 

이번에는 밝기 조절입니다.

방법은 똑같습니다.


#!/usr/bin/env bash

 

function get_brightness {

  xbacklight -get | cut -d '.' -f 1

}

 

function send_notification {

  icon="preferences-system-brightness-lock"

  brightness=$(get_brightness)

  # Make the bar with the special character ─ (it's not dash -)

  # https://en.wikipedia.org/wiki/Box-drawing_character

  bar=$(seq -s "─" 0 $((brightness / 5)) | sed 's/[0-9]//g')

  # Send the notification

  dunstify -i "$icon" -r 5555 -u normal "    $bar"

}

 

case $1 in

  up)

    # increase the backlight by 5%

    xbacklight -inc 5

    send_notification

    ;;

  down)

    # decrease the backlight by 5%

    xbacklight -dec 5

    send_notification

    ;;

esac


출처: https://gist.github.com/Blaradox/030f06d165a82583ae817ee954438f2e

 

사용 예시를 보이고 싶지만 스크린샷 용량으로 인해 올리지 못하네요

볼륨 조절과 똑같은데 아이콘만 다르니 중요하지 않아 그냥 넘어갑니다.

 

게시판 글쓰기에서 코드 들여쓰기가 정상적으로 출력되지 않네요

감안하고 사용하시기 바랍니다.

 

 

  1. 우박 보신 분 있나요 ?

    Date2023.12.06 By김이박 Views571 Votes0
    Read More
  2. 저 또 질문요...

    Date2021.12.16 By뇌성마비중증입니다 Views572 Votes0
    Read More
  3. 정보자산의 보안 강화를 위한 인증 솔루션의 보안 취약점

    Date2024.01.24 ByBaroPAM Views572 Votes0
    Read More
  4. 부팅 시 나타나는 부트 선택 스크린(검정색)

    Date2020.11.20 By코코멜로디 Views573 Votes0
    Read More
  5. 주분투 마우스 포인터 테마 바꾸기

    Date2022.01.01 By뇌성마비중증입니다 Views573 Votes0
    Read More
  6. 요즘 새로운 분들이 많이 유입되어서 좋네요

    Date2023.06.21 Byleaveoiop Views573 Votes0
    Read More
  7. 쳇지피티 유료

    Date2023.03.19 By아무카 Views574 Votes0
    Read More
  8. 멋진 새들에 반란

    Date2018.03.06 Byyoung1004 Views575 Votes0
    Read More
  9. 버추얼박스 디스크를 로컬설치된하모니카에 마운트 할 수 있을까요?

    Date2020.12.28 ByJapser Views575 Votes0
    Read More
  10. 컴터 할때 보조 도구

    Date2023.01.31 By다찌마와 Views575 Votes0
    Read More
  11. [서울특별시/SBA서울산업진흥원] 비전공자도 가능! 새싹(SeSAC) 마포캠퍼스 UIUX 퍼블리싱 실무 프로젝트 과정

    Date2023.04.25 By엑아 Views575 Votes0
    Read More
  12. 9월

    Date2023.08.30 Byblacklink Views575 Votes0
    Read More
  13. 하모니카 페이지 오타

    Date2023.11.11 Bykillsystem10 Views575 Votes0
    Read More
  14. 맥북 패러럴즈에 하모니카를 설치할 수 있나요.?

    Date2023.11.20 By홍반장 Views575 Votes0
    Read More
  15. 안녕하세요~

    Date2021.01.15 By희윤 Views576 Votes0
    Read More
  16. 벌써 내일이면 주말이네요

    Date2022.07.22 Byjamin56 Views576 Votes0
    Read More
  17. 리눅스 커뮤니티예요.

    Date2021.10.31 By잘몰라요. Views577 Votes0
    Read More
  18. 음원 사이트 음악을 들을 수 있는 플레이어가 있을까요?

    Date2022.07.12 By잘몰라요. Views577 Votes0
    Read More
  19. 카톡 채널방 운영방법

    Date2022.10.20 By해중이 Views577 Votes0
    Read More
  20. 하모니카 설치중 실패.... 어떻게 해야 할까요..

    Date2022.11.07 By비케이 Views577 Votes0
    Read More
Board Pagination Prev 1 ... 16 17 18 19 20 21 22 23 24 25 ... 94 Next
/ 94
CLOSE