Poweroff PC when X closes

Hello.
I'm currently trying to setup a very minimal installation for showing presentations.
I've gotten the X server to start at boot by overwriting the systemd service getty@tty1 to run startx instead of agetty.
I've also gotten libreoffice to autostart using .xinitrc.
However when I exit libreoffice the xserver quits and just restarts inclusive libreoffice.
I would like to poweroff the PC as soon as libreoffice quits.
I tried appending "systemctl poweroff" to my .xinitrc (after libreoffice), but for some reason it doesn't get executed.
/etc/systemd/system/[email protected]/override.conf:
[Service]
ExecStart=
ExecStart=-/bin/su [i]username[/i] -l -c /usr/bin/startx
~/.xinitrc
#starting soffice.bin directly to prevent having oosplash running in the background
/usr/lib/libreoffice/program/soffice.bin --impress --norestore --nologo
#Also tried this without exec
exec systemctl poweroff

I just managed to fix it.
I ran 'loginctl show-session $XDG_SESSION_ID' once as normal user and once from .xinitrc and noticed, that the .xinitrc wasn't even run as a real session. (Probably because startx is called by su, which is called directly by systemd)
That's probably the reason why systemctl didn't poweroff my PC when running from .xinitrc, but only when running as a user.
I fixed it by replacing 'exec systemctl poweroff' with 'sudo poweroff' in my .xinitrc and adding 'ALL hostname=NOPASSWD: /usr/bin/poweroff' to /etc/sudoers.

Similar Messages

  • [Closed] KDE Crash Handler appearing when programs close properly

    I've been having this problem with KDE 4.8 and 4.9. The KDE Crash Handler is popping up every so often when I close a program, telling me that the program crashed when it didn't. It occurs every time I close KLook (a quick viewer for Dolphin). It also occurs every time I log out or poweroff from KDE, reporting that Plasma Desktop Shell and then KWin have crashed. The dialogs prevent the system from doing anything until I dismiss them, then the system logs off/shuts down normally.
    If anyone else is having this problem as well, speak up and we can submit a bug report. I have not yet because I am not sure if this is just an issue with my system or if there is a way to simply prevent the Crash Handler from opening (and I would also have to install debugging packages!)
    Last edited by bicyclingrevolution (2012-09-02 06:34:07)

    I did some searching on the Bugtracker (after finding the actual name of the Crash Handler is drkonqi) and discovered that this problem (apps crashing when logging off) goes back to KDE 3 and has never been solved from what I could see. This bug report has been ongoing since 2005! The original poster has a simple solution though: remove the binary! I'll probably do that, since I really don't find it to be any use.
    This report says you can turn it off with KDE_DEBUG 1 (maybe it was supposed to be 0?) but I don't know where I would set that. KDM config files maybe.
    EDIT:
    I renamed /usr/lib/kde4/libexec/drkonqi and am now blissfully free of the crash dialog. KLook works perfectly. Logging out is still slow: nothing happens, then blanks, then pops back up with Plasma and the last desktop, then blanks and continues. It's not smooth, but now I don't have to fiddle with it just to log off.
    I hope the devs will fix this for KDE 5.
    Last edited by bicyclingrevolution (2012-09-02 06:33:03)

  • Sometimes I can't get out of Day view in iCal.  There is no where on the screen to select month view, even when I close it out and go back into iCal.

    Sometimes I am locked in "day" view in iCal.  There is no where on the screen to choose "month" view, even when I close it out and open again.  Tapping anywhere on the screen or scrolling doesn't help.

    Give this a try:
    1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
         User/Home/Library/ Preferences folder.
    2 - delete the contents the following folder: User/Library/Containers/com.apple.iPhoto
    3 - reboot, launch iPhoto and try full screen again.
    NOTE: For Mavericks and Yosemite,  go to your Home folder and use the View ➙ Show View Options menu to bring the this window:
    where you can check the Show Library Folder checkbox.

  • How do i run an external monitor with my macbook and change settings so that when i close the lid the signal to the monitor is not lost and i can continue using the mac with a mouse and a wireless keyboard?

    How do i run an external monitor with my macbook and change settings so that when i close the lid the signal to the monitor is not lost and i can continue using the mac with a mouse and a wireless keyboard?

    No, nothing will prevent the computer from going to sleep when you close its display except third-party hacks that are designed to do exactly that. I strongly advise against using any of those, as they may interfere with successful entry into clamshell mode (and they carry other downside risks as well). Just wait until the computer is asleep (with its sleep light pulsing), then press any key on the keyboard. It sounds as though your setup is working as it's designed to do.

  • Since I installed Lion on my macbook the LED light does not pulse when I close the screen - the sleep function does not work.

    Since I installed Lion on my macbook the LED light does not pulse when I close the screen - the sleep function does not work neither when chosen after pressing the button nor chosen in the apple menu..

    I have had the same problem but on another forum it was suggested that disabling internet sharing would solve this. This fix seems to work on my machine - why it works I do not understand

  • After upgrading to the newer version of Firefox, a lose all my tabs every time I close. I've done what was suggested in the FAQx, but I still lose them all when I close. I want to fix this. How?

    I want to know how to have my tabs save when I close Firefox. I did what was suggested in the FAQs section, but all my tabs disappear every time I close Firefox, whether using the "exit" command, or the "X" button. This was the very reason I never updated to the new version previously, but had hoped that the problem had been addressed and upgraded, now I'm stuck with having to reopen every tab every time I open Firefox. Please tell me there is a way to correct this. And, I'm not fluent in technospeak, so I need simple, basic instructions. Thank you. Mark

    Hi,
    Pressing '''Alt''' + '''T''' on the keyboard brings up the '''Tools''' menu.
    To see the full menu bar temporarily, press '''Alt''' or '''F10'''.
    To make the menu bar permanently visible, right-click on the '''+''' after the last tab and enable (tick) '''Menu Bar''' or press '''Alt''' + '''V''' > '''Toolbars''' > '''Menu Bar'''.
    [https://support.mozilla.com/en-US/kb/Options%20window All about Tools > Options]
    [https://support.mozilla.com/en-US/kb/Keyboard%20shortcuts Keyboard Shortcuts]
    Useful links:
    [http://kb.mozillazine.org/About:config Going beyond Tools > Options - about:config]
    [http://kb.mozillazine.org/About:config_entries about:config Entries]
    [https://support.mozilla.com/en-US/kb/Page%20Info%20window Page Info] Tools (Alt + T) > Page Info, Right-click > View Page Info
    [https://support.mozilla.com/en-US/kb/Viewing%20video%20in%20Firefox%20without%20a%20plugin Viewing Video without Plugins]
    [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder & Files]
    [https://developer.mozilla.org/en/Command_Line_Options#Browser Firefox Commands]
    [https://support.mozilla.com/en-US/kb/Basic%20Troubleshooting Basic Troubleshooting]
    [https://support.mozilla.com/en-US/kb/common-questions-after-upgrading-firefox-36 After Upgrading]
    [https://support.mozilla.com/en-US/kb/Safe%20Mode Safe Mode]
    [http://kb.mozillazine.org/Problematic_extensions Problematic Extensions]
    [https://support.mozilla.com/en-US/kb/Troubleshooting%20extensions%20and%20themes Troubleshooting Extensions and Themes]
    [https://support.mozilla.com/en-US/kb/Troubleshooting%20plugins Troubleshooting Plugins]
    [http://kb.mozillazine.org/Testing_plugins Testing Plugins]

  • I've connected my macbook pro (os 10.6.8) to an external display, but it will not go into clam shell mode!  When I close the lid the laptop goes to sleep, and I am unable to wake it using the external keyboard or mouse.

    A rundown of what I've tried:
    Adjusting energy settings to try to prevent sleep
    Pluging the USB keyboard and wacom tablet directly into the laptop (as opposed to a usb hub)
    My laptop's power cable is connected
    My display (a Vizio TV) is recognized in the System Preferences panel
    I'd been using this TV for about a year with my older Macbook Pro (OS 10.5.8), though using a different wireless keyboard and mouse
    ***Update:  The issue seems to lie with the keyboard and wacom tablet.  I am trying to use a wireless Case Logic keyboard (with dongal) and wired wacom tablet to wake the Macbook Pro in clamshell mode.  To experiment, I tried using my Logitech wireless keyboard & mouse set (also dongal) that I had been using before and it wakes the computer without any problems!  However, I really need to be able to use my wacom tablet.  If I switch to the tablet after waking the computer using the Logitech keyboard & mouse it works, but once the computer sleeps it won't work anymore.  I could keep switching back and forth I suppose, but it's sort of a pain.  There has to be an easier way!  Any ideas why the wired wacom tablet is unable to wake the computer in clamshell mode?
    Thanks!

    So your keyboard or mouse won't wake the Mac when you close the lid correct? Try resetting the SMC and pram
    Shut down the computer.
    Disconnect the MagSafe power adapter from the computer, if it's connected.
    Remove the battery.
    Press and hold the power button for 5 seconds.
    Release the power button.
    Reconnect the battery and MagSafe power adapter.
    Press the power button to turn on the computer.
    Resetting NVRAM / PRAM
    Shut down your Mac.
    Locate the following keys on the keyboard: Command (⌘), Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.

  • When I close out a website it goes to my desk top and then tells me firefox is running and I have to shut down the system

    when I close out a website it goes to my desk top and then tells me firefox is already running and I have to shut down my system and bring it back up and wait to log back in. It's quite frustrating.

    Try Ctrl>ALT>DEL then click Start Task Manager, then find the process firefox.exe, then click end program, then try opening Firefox again. <!-- click applications > new task.... > explorer.exe --> done! If that doesn't work, then try re-installing Firefox or going to this link to safe mode area and click continue to safe mode and then try and exit, if this problem still occurs then disable extensions and plugins

  • My homepage will load about 30% and then i'm dead in the water. when i close firefox it appears to close but when i try to reopen it tells me that it's already running. started with beta 6 i deleated and loaded ver 5 no change

    when i start firefox, everything starts normal then my homepage (igoogle) starts to load, gets to about 30% and stops. from there i can click on links or bookmark and a new tab will open but no page will load. i can't get anywhere. then when i close firefox it appears to close normally but when i try to reopen firefox i get a message that firefox is still running but not responding and the only way to shut it down is to reboot. when it first occured i was running beta 6 (since it became available, i also used beta 4 & beta 5) i then uninstalled beta 6 and downloaded and installed ver 5 same problem. i then did a system restore to a time before the problem.. no luck. i'm not sure what to try next. IE & chrome both work fine

    I'm in exactly the same boat - dead at blue screen, only option is to salvage using target mode.
    I don't currently have access to another Mac to do target mode. I was planning to buy a new Mac this fall anyway, though. 2 questions in preparation for that purchase:
    1) Is there anything I can do before buying a new Mac to make the salvage process more successful? ie, should I spend the time and money going to the genius bar to have them help me get from totally crippled to partially crippled? (As for expertise, I'm a proficient consumer-grade user, but Apple Support walked me through the safe-boot process, etc.)
    2) Is Apple going to provide 10.5 once it is released to people who buy a new Mac in these 6 weeks pre-release?
    Thanks for your help,
    Bailey

  • HT3382 I have a Samsung VGA Monitor connected to my MacBook Pro using the Mini Display Port to VGA Adapter.  How do I configure the computer so that it doesn't sleep when I close the lid of the computer.

    I have a Samsung VGA Monitor connected to my MacBook Pro using the Mini Display Port to VGA Adapter.  How do I configure the computer so that it doesn't sleep when I close the lid of the computer.

    Hi alangium,
    Welcome to the Support Communities!
    Resetting your computer's PRAM should restore your Macbook Pro's screen appearance.
    OS X Mavericks: Reset your computer’s PRAM
    http://support.apple.com/kb/ph14222
    This article may provide some information about your Mini DisplayPort to AVI adapter.  Have you tried to connect a different VGA monitor to your Macbook to see if you get the same results?
    Apple Mini DisplayPort adapters: Frequently asked questions (FAQ)
    http://support.apple.com/kb/HT3382
    18. What is the maximum resolution available for use with the Apple Mini DisplayPort to VGA adapter?
    The resolution available with the Apple Mini DisplayPort to VGA Adapter is 1920 x 1200. VGA displays that use higher refresh rates (such as 85 Hz) at resolutions of 1600 x 1200 or greater may not generate video properly until you lower the refresh rate.
    Apple computers: Troubleshooting issues with video on internal or external displays
    http://support.apple.com/kb/HT1573#5
    How can I detect displays?
    If the detect displays option is not available, hold down the Option key while you are in the Display pane.
    How do I select additional resolutions on my display?
    You can use the Display pane of System Preferences to specify how your display works. Not all options appear for all display models. By default the best resolution for your display will already be selected in System Preferences.
    To select a different resolution, use the Scaled option. Some additional resolutions may be available when you hold the Option button.
    I hope this information helps ....
    - Judy

  • My macbook pro won't go to sleep when I close the lid

    I've been having this problem for a couple of years now, and it's getting pretty annoying.
    I got this MacBook Pro in April of 2011. Otherwise, it works great. It goes to sleep when I go up to the apple menu and select "sleep." BUT, when I close the lid, it stays on. Heaven forbid I don't have it plugged in, because then the battery will be shot! It also won't go to sleep automatically when I leave it for a long time. Yet another potential battery drain.
    How do I fix it so that it goes to sleep automatically when I close the lid and when I leave it alone for a while?
    In Energy Saver, I have checked all the boxes necessary: "Put the hard disk(s) to sleep when possible" "Wake for network access" and "Automatically reduce brightness before display goes to sleep."  
    Am I missing something here, or does my computer just have a defect?

    I had the same issue.
    I used an external monitor but all of a sudden when I closed the lid my Macbook Pro did not go to sleep!
    I solved the problem with a SMC reset.
    Try to do it...

  • I have a problem when i close the prgram and i open it agin it open on the page which i closed at it

    when i close firefox at any page and also when i close my pc and then i open the program i find it open on last page which i closed at ,, although i made home page for it to open at and it doesn't make the order

    Check in preferences > general > Startup: Do you have "Show my windows and tabs from last time" selected? If so change to "Show my home page" (or blank page).
    Note: this may happen when quitting Firefox, and you inadvertently click "Save and Quit" and select "Do not ask next time".

  • When i close firefox and want to use it later i get a warning saying cannot open firefox close it first this keeps happening all the time any ideas to solve this problem? i have 2 mchines one on xp and one on windows 7

    i have 2 pcs one with xp and the other with windows 7 heres the problem
    when i close firefox and say go back to it say in 10 mins i get a error message saying to close firefox before opening!!! but firefox window is closed but the processes still say its running in task manager so to correct this i have to end process on firefox. this seems to be happening now every time in the last few days i have upgraded firefox to the latest version. any ideas on how to solve this problem.

    see if this helps you : [https://support.mozilla.org/en-US/kb/Firefox%20is%20already%20running%20but%20is%20not%20responding Firefox is already running but is not responding]
    thank you
    Please mark "Solved" the answer that really solve the problem, to help others with a similar problem.

  • FF doesn't open a new window , and doesn't open at all when I close it and try to open it again.

    Initially when I start my PC Windows 7 Ultimate , FF opens fine , but it doesn't open a new window when I click on the option "Open a new Window " in the taskbar .When I right-click a tab and select the option "Move to a new Window" then too it doesn't work. Next when I close FF and and try to reopen it , it doesn't open at all.I have FF v34.0.5.

    Gnome-shell issue. You can disable desktop management as a temporary fix, but the next gnome-shell update will fix the problem.
    https://bbs.archlinux.org/viewtopic.php?id=175993
    https://bugzilla.gnome.org/show_bug.cgi?id=722510
    https://bugzilla.gnome.org/show_bug.cgi?id=722690

  • When I close my iPhone and I want to open it to use it again, the opening process takes more than an hour, I regretted to buy the iPhone because of this problem that you do not suffer at all with Nokia,how I can solve this problem?

    When I close my iPhone and I want to open it to use it again, the opening process takes more than an hour, I regretted to buy the iPhone because of this problem that you do not suffer at all with Nokia,how I can solve this problem?

    mostafa182 wrote:
    ... how I can solve this problem?
    The Basic Troubleshooting Steps are:
    Restart... Reset... Restore from Backup...  Restore as New...
    Restart / Reset
    http://support.apple.com/kb/ht1430
    Backing up, Updating and Restoring
    http://support.apple.com/kb/HT1414
    If you try all these steps and you still have issues... Then a Visit to an Apple Store or AASP (Authorized Apple Service Provider) is the Next Step...
    Be sure to make an appointment first...

Maybe you are looking for

  • F110 Automatic Payment program

    Hi , We have an issue in th Automatic payment program F110. We have a few vendor invoices ( 1500 euros )  for a vendor X. There is also a credit memo for that vendor (100 Euros ). When we run F110  the credit memo is going to the Exception list with

  • Mac Pro 1.1 processor upgrade

    I have a Mac Pro 1.1 and would request that this be put into i7 processor? The machine has 2 x 3GHz dual core processor. If it can be replaced on what should be done?

  • Cs5 licence: change from Windows to Mac?

    Can i chance my Cs5 windows licence to a Mac licence ?

  • Cluster servlet only sees one server

              I'm using WLS6.1 SP2 running on Solaris. I'm using the new version of the HttpClusterServlet           (weblogic.servlet.proxy.HttpClusterServlet) to proxy to 6 managed servers running           on two physical servers. It's just proxying w

  • Account not in this store FIX (Step by step) iphone

    The quick fix for most people is: 1) Find the 'Settings' icon on your iphone screen. Tap to enter. 2) Scroll down to the tab labled 'iTunes & App Stores'. Tap to enter. 3) At the top is a tab labled with your email, eg: 'Apple ID: [email protected]'.