LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-01-2021, 04:15 PM   #1
Neljor
LQ Newbie
 
Registered: May 2020
Location: Seattle, US
Distribution: OpenSuSE
Posts: 21

Rep: Reputation: Disabled
Bash script for KDeplasma login.


Dear people,
Created a script to be executed at KDE login, the script works fine after login but cannot be executed at login (autostart), likely because pulse is not loaded completely yet.

Do you have any advice on this?
Thanks in advantage!

Code:
FILE="/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/interface"
SCARLETT="Scarlett 2i2 USB"

test -f "$FILE" && head -n 1 "$FILE" | while read -r name
        do
         if  [ "$name" = "$SCARLETT" ]; then
        pacmd load-module module-remap-source source_name=mono master=alsa_input.usb-Focusrite_Scarlett_2i2_USB_Y81V7690CABC66-00.analog-stereo master_channel_map=front-left,front-right channel_map=mono,mono
        fi
       done

exit 0
 
Old 04-02-2021, 07:31 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,402
Blog Entries: 28

Rep: Reputation: 6166Reputation: 6166Reputation: 6166Reputation: 6166Reputation: 6166Reputation: 6166Reputation: 6166Reputation: 6166Reputation: 6166Reputation: 6166Reputation: 6166
You could add a sleep command at the top of the script to delay execution until Plasma is fully loaded. See man sleep for more.
 
1 members found this post helpful.
Old 04-03-2021, 08:27 AM   #3
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,843

Rep: Reputation: 1222Reputation: 1222Reputation: 1222Reputation: 1222Reputation: 1222Reputation: 1222Reputation: 1222Reputation: 1222Reputation: 1222
Perhaps with 3 delayed attempts:
Code:
FILE="/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/interface"
SCARLETT="Scarlett 2i2 USB"
for trial in 1 2 3
do
  sleep 2
  if
    test -f "$FILE" &&
    read -r name &&
    [ "$name" = "$SCARLETT" ]
  then
    pacmd load-module module-remap-source source_name=mono master=alsa_input.usb-Focusrite_Scarlett_2i2_USB_Y81V7690CABC66-00.analog-stereo master_channel_map=front-left,front-right channel_map=mono,mono
    break
  fi
done

exit 0
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Running bash script from another bash script bulletproof.rs Programming 5 12-10-2017 04:22 AM
[SOLVED] BASH Script - What am I doing wrong in this test? - BASH Script BW-userx Programming 34 04-08-2017 01:36 PM
how to disable "last login log" & disable "last login message" when start login. hocheetiong Linux - Newbie 4 02-08-2011 05:35 AM
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 08:56 AM
Bash script to create bash script jag7720 Programming 10 09-10-2007 07:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration