LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 01-18-2018, 03:32 AM   #1
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Rep: Reputation: 8
Clonning Linux desktop to Apple TV


Below small script for cloning Linux desktop over network to Apple TV:

Code:
#!/bin/bash
if [ -f ~/tmp/apple ]
then
proc=`cat ~/tmp/apple`
kill -9 $proc 
rm -f ~/tmp/apple 2>/dev/null
kdialog --passivepopup "End of cloning to Apple TV" 5 2>/dev/null
else
choice="$(avahi-browse _airplay._tcp -ptr|grep IPv4|awk -F';' '{print $7}'|grep -v ^$|zenity --list --hide-header --title="Apple TV" --text="Choose Apple TV..." --column="IP adresses" 2>/dev/null)"
if [ -z "$choice" ] 
then
kdialog --passivepopup "Error - no Apple TV chosen" 5 2>/dev/null
exit
else
PASSWD="$(zenity --password --title="Enter password")"
if [ -z "$PASSWD" ]
then
java -jar ~/Pobrane/airplay.jar -h "$choice" -d >~/tmp/apple_wyn 2>&1 &
proc=$!
else
java -jar ~/Pobrane/airplay.jar -h "$choice" -a $PASSWD -d >~/tmp/apple_wyn 2>&1 &
proc=$!
fi
sleep 2
error=`ack -1 --match password ~/tmp/apple_wyn`
if [ ! -z "$error" ]
then
        kdialog --passivepopup "Wrong password" 5 2>/dev/null
        kill -9 $proc
        exit
fi
kdialog --passivepopup "Cloning desktop to Apple TV" 5 2>/dev/null
echo $proc > ~/tmp/apple
fi
fi
It works properly when I run it from console. But if I define lunch icon on desktop in KDE environment, it seams to not execute line:

Code:
error=`ack -1 --match password ~/tmp/apple_wyn`
Any idea what is the problem?
 
Old 01-19-2018, 09:11 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Maybe it doesn't like backticks (are they UTF-8 special chars?)
Did you try to replace with
Code:
error=$(ack -1 --match password ~/tmp/apple_wyn)
 
Old 01-19-2018, 11:58 AM   #3
bryanthhen
LQ Newbie
 
Registered: Jan 2018
Posts: 7

Rep: Reputation: Disabled
it is really awesome, great
 
Old 01-19-2018, 11:59 AM   #4
bryanthhen
LQ Newbie
 
Registered: Jan 2018
Posts: 7

Rep: Reputation: Disabled
thanks for sharing

it is awesome, thanks for sharing
great
 
Old 01-20-2018, 07:57 AM   #5
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
Quote:
Originally Posted by keefaz View Post
Maybe it doesn't like backticks (are they UTF-8 special chars?)
Did you try to replace with
Code:
error=$(ack -1 --match password ~/tmp/apple_wyn)
Hmm. It still works when I run it from console. From KDE desktop define icon = no. I use only English ASCII characters as a password. But for example if I run script from desktop icon and enter blank password (Apple TV has already password assigned)
the lines
Code:
error=`ack -1 --match password ~/tmp/apple_wyn`
if [ ! -z "$error" ]
seams to not work. I have to mention once more that running script for console, works properly.
 
Old 01-20-2018, 06:17 PM   #6
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
I was simply suggesting that whatever interprets .desktop file might not like the backticks ` so why not try the bash $() syntax instead?

Also are sure that error comes from this line? I mean you see a Kdialog popup with "Wrong password" message?

Last edited by keefaz; 01-20-2018 at 06:25 PM.
 
Old 01-21-2018, 02:17 AM   #7
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
Finally I got it working. But really dont know what is the difference in fuctionality.
So instead the lines:

Code:
error=`ack -1 --match password ~/tmp/apple_wyn`
if [ ! -z "$error" ]
I placed:

Code:
error=`tail ~/tmp/apple_wyn|grep password|wc -l`
if [ $error -ne "0" ]
Now it works both started from ASCII console and from custom defined icon on KDE desktop.
But
 
Old 01-26-2018, 11:44 AM   #8
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Rep: Reputation: 111Reputation: 111
my bet is that ack behaves differently when started from the "desktop" than from a terminal.
Ubuntu seems to have various of such tools, that make it quite hard to predict what they will do. There are workarounds for those commands I think, to make them behave more similar.
 
  


Reply

Tags
ack, apple, bash, kde



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
LXer: Linux Foundation Head Calls 2017 ‘Year of the Linux Desktop’…. While Running Apple’s macOS Himself LXer Syndicated Linux News 0 09-14-2017 03:33 AM
LXer: How Apple killed the Linux desktop LXer Syndicated Linux News 6 08-29-2012 07:56 AM
LXer: Can Apple clear the way for the Linux desktop? LXer Syndicated Linux News 0 03-04-2007 06:31 PM
LXer: How Apple and Microsoft are advancing desktop Linux LXer Syndicated Linux News 0 06-24-2006 02:54 PM
clonning linux with tar gobexe Linux - Software 1 03-24-2006 07:22 AM

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

All times are GMT -5. The time now is 11:32 PM.

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