LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-09-2021, 10:09 AM   #1
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 5,738

Rep: Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271
Is this Node.js and can it be changed to return without action?


Microsoft Teams for Linux has the annoying habit of automatically populating the user's autostart file when run after being installed or updated. I know this can be turned off from within teams, but I would prefer that this behaviour did not happen.
Looking at the /usr/share/teams/resources/app.asar file in the latest version of teams (1.4.00.13653), I have identified this code snippet that I have tried to format for readability.
The 'writeFileSync' suggests this might be Node.js, of which I have no knowledge
Code:
setUpLinuxAutoStartFile(e){
 const t=r.join(c.homedir(),".config","autostart"),
 n=r.
 join(t,p.getAppName()+".desktop");
try{if(e.openAtLogin){s.existsSync(t)||s.mkdirSync(t,{recursive:!0});
 const e=["[Desktop Entry]",
 "Version=1.0",
 "Type=Application",
 "Encoding=UTF-8",
 "Name="+p.getAppDisplayName(),
 "Exec=/usr/bin/"+p.getAppName()+" %U",
 "Icon="+p.getAppName(),
 "Terminal=false",
 "StartupNotify=false",
 "Categories=Network;Application;",
 "MimeType=x-scheme-handler/msteams;",
 "X-GNOME-Autostart-enabled=true",
 "X-KDE-Protocols=teams"].join("\n");
 s.writeFileSync(n,e)}
else
 s.existsSync(n)&&s.unlinkSync(n)}catch(t){h.getInstance().logWarning("Error occurred while working with autoStart file "+n+";
 was writing file = "+e.openAtLogin+"; error: "+p.sanitizeError(t))}}
Any thoughts on how to get this to be a NOOP?
 
Old 09-09-2021, 10:56 AM   #2
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 1,618

Rep: Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315Reputation: 1315

Well code cannot "be" Node.js, because Node.js is a runtime environment, not a programming language.

The code might be JavaScript, which is the language Node.js uses, but it might be another language with similar syntax. (There's no guarantee that s.writeFileSync is the same as Node's fs.writeFileSync function.)

Given that Microsoft Teams is written in TypeScript there's a fair chance that's what the snippet is.


Anyway, the important bit is preventing doing unwanted stuff, and we can probably do that without confirming specifics.

The bulk of the code appears to be contained within a condition - "if(e.openAtLogin){...}" - you can easily disable it by making it always false - for which prefixing with "false&&" should work, i.e: "if(false&&e.openAtLogin){...}"

(If that doesn't work, try with "0" or instead of "false", or perhaps try "False and " instead.)

Or actually just insert "return;" immediately after the first "{" will be an even simpler method that will exit the function without doing anything.

 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
rhel 2 node cluster: resources do not move to second node when node halted tapuhi Linux - Software 1 03-01-2015 10:41 AM
node recovery when the node becomes fault by using another node to replace it jerinc Linux - Wireless Networking 0 02-21-2014 05:44 PM
How to transfer the services from node 1 to node 2 ,if node 1 is directly turned off sankarg304 Linux - Server 1 12-12-2012 10:06 AM

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

All times are GMT -5. The time now is 02:27 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